stack-memory Questions

7

Solved

How do i manually initiate values in array on heap? If the array is local variable (in stack), it can be done very elegant and easy way, like this: int myArray[3] = {1,2,3}; Unfortunately, follo...
Oregano asked 31/12, 2010 at 16:30

1

Solved

When we run a code, the compiler after compile "detects" the necessary amount of Stack memory? And with this, each program has its own "block" of stack memory. Or the stack memo...
Marchpast asked 18/10, 2021 at 23:52

2

Solved

I'm trying to understand the behavior of pushing and popping the stack pointer register. In AT&T: pushl %esp and popl %esp Note that they store the computed value back into %esp. I'm consider...
Hungary asked 19/2, 2013 at 22:30

2

Solved

Is there a way I can measure how much stack memory a function uses? This question isn't specific to recursive functions; however I was interested to know how much stack memory a function called re...
Scut asked 13/8, 2016 at 5:27

9

Solved

I am getting confused with memory allocation basics between Stack vs Heap. As per the standard definition (things which everybody says), all Value Types will get allocated onto a Stack and Referenc...
Twiggy asked 20/12, 2010 at 6:2

1

Solved

I'm aware that Rust allocates on the stack by default, but the paper Ownership is Theft says that Rust closures are typically allocated dynamically (which I took to mean "on the heap").
Tanhya asked 15/2, 2021 at 15:16

7

Solved

I want to do DFS on a 100 X 100 array. (Say elements of array represents graph nodes) So assuming worst case, depth of recursive function calls can go upto 10000 with each call taking upto say 20 b...
Kacey asked 1/12, 2009 at 12:42

2

Solved

I'm just asking why Rust decided to use &str for string literals instead of String. Isn't it possible for Rust to just automatically convert a string literal to a String and put it on the heap ...
Seymour asked 25/8, 2020 at 4:39

8

Allocating stuff on the stack is awesome because than we have RAII and don't have to worry about memory leaks and such. However sometimes we must allocate on the heap: If the data is really big (...
Baroja asked 10/10, 2014 at 9:32

7

Solved

The following code creates an object on the stack: Object o; When creating an object on the heap we can use: Object* o; o = new Object(); rather than: Object* o = new Object(); When we sp...
Erebus asked 14/4, 2012 at 20:31

2

I'm reading a textbook which shows assembly code based on C code: C code: void echo() { char buf[8]; otherFunction(buf); } assembly code: echo: subq $24, %rsp //Allocate 24 bytes on stack, but ...
Matri asked 21/7, 2020 at 7:0

1

Solved

Because of a lack of PUSH and POP instructions in ARM64, I'm having a problem with understanding how SP work in ARM64. If I were to PUSH/POP, does the SP decrement/increment by 4, 8 or 16 bytes? I'...
Alluring asked 20/7, 2020 at 20:20

9

I read lot of articles about garbage collection and almost all article tells about heap memory. so my question is "garbage collection collects stack memory or heap memory or both".

4

Solved

I am trying to call a method that will generate a 2D char array (array of strings) and return it to be used in another function. My example: char ** example(void) { char *test[3]; int i; for ...
Two asked 11/12, 2015 at 15:56

1

Solved

From What is the purpose of the _chkstk() function?: At the end of the stack, there is one guard page mapped as inaccessible memory -- if the program accesses it (because it is trying to use ...
Coverup asked 4/2, 2020 at 13:51

6

Solved

In C, I know I can dynamically allocate a two-dimensional array on the heap using the following code: int** someNumbers = malloc(arrayRows*sizeof(int*)); for (i = 0; i < arrayRows; i++) { som...
Mcwhorter asked 2/4, 2010 at 4:46

5

Solved

How can I take an object-as-value result from a method call and place it on the heap? For instance: The Qt QImage::scaledToWidth method returns a copy of the QImage object. Right now I'm doing:...
Mekka asked 27/9, 2011 at 15:0

5

Solved

Are all of the following statements true? vector<Type> vect; //allocates vect on stack and each of the Type (using std::allocator) also will be on the stack vector<Type> *vect = new v...
Elvera asked 7/11, 2011 at 12:25

2

Solved

NASM Assembly, Ubuntu, 32-bit program. Normally, when popping a value from the stack, I'll do POP somewhere Into a register or a variable. But sometimes, I simply don't want to put it anywhere ...
Rondo asked 17/10, 2013 at 5:16

1

I have a few questions about Stack Guard and SSP protections. First question is about Stack Guard and its three types of canaries, if I am correctly - terminator, random and random XOR. I'd like t...
Drummer asked 18/1, 2015 at 20:47

4

Solved

I have tried to allocate space for 10^7 integers in heap and stack memory to see which one is faster. Obviously allocating in heap-memory was much faster but I don't understand the reason. #includ...
Pentylenetetrazol asked 30/7, 2019 at 14:19

2

Is there a relation between endianness of a processor and the direction of stack growth? For example, x86 architecture is little endian and the stack grows downwards (i.e. it starts at highest add...
Campy asked 27/8, 2013 at 15:43

7

Solved

I know this sounds like a general question and I've seen many similar questions (both here and on the web) but none of them are really like my dilemma. Say I have this code: void GetSomeData(char...
Mirandamire asked 5/6, 2014 at 10:9

2

Solved

I am currently learning the basics of assembly and came across something odd when looking at the instructions generated by GCC(6.1.1). Here is the source: #include <stdio.h> int foo(int x, i...
Sustainer asked 5/8, 2016 at 4:27

1

Solved

I'm trying to link x86 assembly and C. My C program: extern int plus_10(int); # include <stdio.h> int main() { int x = plus_10(40); printf("%d\n", x); return 0; } My assembly program...
Perth asked 13/5, 2019 at 13:51

© 2022 - 2024 — McMap. All rights reserved.