?
=?ISO-8859-1?Q?Martin_J=F8rgensen?=
Hi,
I have a (bigger) program with about 15-30 malloc's in it (too big to
post it here)... The last thing I tried today was to add yet another
malloc **two_dimensional_data. But I found out that malloc always
returned null at this moment and the program exited (even though if I
malloc'ed only 20 bytes or something)... Then I googled for this problem
and found something about a memory pool??? Is that standard C?
I didn't understand it, but it said something about that it was possible
to choose the size of the memory pool to be like 4 kb (or whatever)...?
I copy/pasted the code, but it didn't work...
Then I came to think of this "heap"-thing which I never really
understood. Is there any size limit on this "heap"? And can I have more
than 20-30 malloc's in my program without any trouble?
My solution was to allocate this two_dimensional_data-array statically
(declared it as "double two_dimensional_data[15][15]"), but I prefer the
dynamically method if possible...
And suppose at some moment I need to allocate 200 MB RAM. AFAIR this
isn't possible even though the system has that amount of memory free?
What could one do in such a case?
Therefore the question: Is there any restrictions with using malloc that
is relevant to know of?
Best regards / Med venlig hilsen
Martin Jørgensen
I have a (bigger) program with about 15-30 malloc's in it (too big to
post it here)... The last thing I tried today was to add yet another
malloc **two_dimensional_data. But I found out that malloc always
returned null at this moment and the program exited (even though if I
malloc'ed only 20 bytes or something)... Then I googled for this problem
and found something about a memory pool??? Is that standard C?
I didn't understand it, but it said something about that it was possible
to choose the size of the memory pool to be like 4 kb (or whatever)...?
I copy/pasted the code, but it didn't work...
Then I came to think of this "heap"-thing which I never really
understood. Is there any size limit on this "heap"? And can I have more
than 20-30 malloc's in my program without any trouble?
My solution was to allocate this two_dimensional_data-array statically
(declared it as "double two_dimensional_data[15][15]"), but I prefer the
dynamically method if possible...
And suppose at some moment I need to allocate 200 MB RAM. AFAIR this
isn't possible even though the system has that amount of memory free?
What could one do in such a case?
Therefore the question: Is there any restrictions with using malloc that
is relevant to know of?
Best regards / Med venlig hilsen
Martin Jørgensen