malloc() return value and available memory...
I''m having this problem with allocating memory (with malloc) for a new variable: it returns NULL (meaning no memory available). What I don''t understand about this is, there should be enough memory available! I can define 100 non-dynamic variables of the same type (a structure) without a problem (was just for testing) and the system resource tells me there''s plenty left!
So, could a NULL mean something different than "no memory available"? Or does malloc have a different address room than non-dynamic variables...? Or what else could be the problem?
Thanks for your help!
PS: I HAD to do this in C... ^^
------------------------------
"Reality is nothing, perception is everything!" - First Wizard Zeddicus Zu''l Zorander
How much memory (in bytes) are you requesting??
Returning a NULL means it cant allocate a block of that size.
You may have enought memory but it may be fragmented all over the place.
It also my be your OS not letting you have the memory.
there might be some limit to how much a single process can have.
Question: "I HAD to do this in C" ? mening what exactly.
Most launguages have a malloc of some description.
Armand.
Returning a NULL means it cant allocate a block of that size.
You may have enought memory but it may be fragmented all over the place.
It also my be your OS not letting you have the memory.
there might be some limit to how much a single process can have.
Question: "I HAD to do this in C" ? mening what exactly.
Most launguages have a malloc of some description.
Armand.
The structure is only 8 bytes... and I can include 100 variables of the same structure if they are non-dynamic!
I worked with C++, Java, C# - pure C is a shock coming from OO.
------------------------------
"Reality is nothing, perception is everything!" - First Wizard Zeddicus Zu''l Zorander
I worked with C++, Java, C# - pure C is a shock coming from OO.
------------------------------
"Reality is nothing, perception is everything!" - First Wizard Zeddicus Zu''l Zorander
[grbrg] Can you put source, how You allocate memory using malloc ?
[edited by - Estor on March 6, 2003 8:00:28 AM]
[edited by - Estor on March 6, 2003 8:00:28 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement