Re: Help with malloc/free:
Re: Help with malloc/free:
- Subject: Re: Help with malloc/free:
- From: Travis Rose <email@hidden>
- Date: Wed, 11 Apr 2007 13:06:19 -0400
Hello,
I should clarify this perhaps a bit more:
Mac OS X (10.4.9, GCC 4.0.1)
The block is not freed from virtual memory;
initialization: int* decomp_data = (int*) malloc(lengthOfBlock); myTableStart[block_number] = decomp_data;
compression:
int* decompress = myTableStart[block_number]; //get the pointer to the block
... do compression ...
free(decompress); //free the block <-- Frees from real memory, not from virtual memory!!!
Travis
On Apr 10, 2007, at 11:10 PM, Shawn Erickson wrote:
I've noticed something strange with malloc and free on Mac OS X.
I have a recursive function that does compression.
In this function, as the data are compressed, I wish to release some previously allocated memory;
For example,
int* decompress = myTableStart[block_number]; //get the pointer to the block
... do compression ...
free(decompress); //free the block <-- this is not having any effect!!!
For some reason, the memory is not freed immediately, so it behaves like a leak ... and the program eventually crashes.
Any ideas on how to fix this?
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden