I am getting some strange behavior with the free memory return value when changing the STACK_SIZE value. I wonder what is the max size of the pool that guarantees that normal ram usage does not collide with the dynamic memory pool.
Thanks.
Dynamic memory pool size
Moderator: Stef
Dynamic memory pool size
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Dynamic memory pool size
What kind of strange behavior did you observed ?
Re: Dynamic memory pool size
For example, i have an amount of free memory returned with MEM_get_free, and after when i change the code to allocate some memory statically instead of dynamically, i get a lower amout of free memory. It is like something overwrites some of the pool zone and get_free reads it like a non-free blocks. That's why i wonder how much of memory can be allocated with STACK_SIZE without interfering with the rest of the RAM usage.
When i change the STACK_SIZE constant i have to change also something in md.ld like the "_bend" value, or something else?
When i change the STACK_SIZE constant i have to change also something in md.ld like the "_bend" value, or something else?
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Dynamic memory pool size
Of course, that is expected. When you statically allocate an object in C, it eats some part of the available heap memory so the dynamic memory manager has less memory to work with.Manveru wrote:For example, i have an amount of free memory returned with MEM_get_free, and after when i change the code to allocate some memory statically instead of dynamically, i get a lower amount of free memory.
For instance if you do that (static allocation) :
Code: Select all
int myArray[1000];
int main()
{
int free = MEM_getFree();
...
}
Code: Select all
int main()
{
int free = MEM_getFree();
...
}
Code: Select all
int myArray[1000];
int main()
{
int free = MEM_getFree();
...
}
Code: Select all
int* myArray;
int main()
{
myArray = MEM_alloc(1000 * sizeof(int));
int free = MEM_getFree();
...
}
Re: Dynamic memory pool size
Oh i see. I understand better now how the memory works, bss and so. Thanks Stef.
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Dynamic memory pool size
You're welcome !