On Apr 11, 2007, at 10:06 AM, Travis Rose wrote: 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;
How do you ascertain this?
free(decompress); //free the block <-- Frees from real memory, not from virtual memory!!!
Are you, by any chance, looking at numbers from e.g. top? If so, please note that things are somewhat more complicated than you may think.
If the size of your allocation is smaller than about 16KiB, then there's a good chance that your allocations are being satisfied by one or more of the heaps, and you will not see a direct correlation between the number of allocations you have made and the virtual space allocated in your process' map.
Eventually, my colleague who was working on this problem learned about some limitations with VM management inherent in running 32-bit code (32-bit pointers) ...
Unfortunately, either you or your colleague are somewhat confused. namely, he observes the VM is actually flushed at 4GB, although the program would crash after 3.4GB use (because of the overhead of the OS is ~0.6GB, in practice, a total 4GB allocation isn't ever achieved for 32-bit);
What do you mean by "flushed"? you might think that the system would detect this problem and flush VM sooner; no such luck.
Here it is clear you are very confused. In the situation where your application has run out of virtual space, there is nothing "the system" can do - you would be incensed if "the system" were to, say, free one of your other allocations and make a new one in its place. As a result, when re-compiling for 64-bit, the program works (i.e., VM gets flushed before running out of memory, etc.)
No; all you get here is a larger virtual address space. If this is indeed generally the case, we think this may be a problem for developers who use the 32-bit default and get surprised later by the "behavior" of VM management.
It is quite clear from messages like this one that developers need to understand how memory management works, yes. Asking "colleagues" is not always the best idea, however. Many developers do suffer from the delusion that virtual space is somehow infinite; it's odd how quickly the lessons of the MS-DOS 640KiB limit have been forgotten.
I would encourage you to consider a small investment in any reputable operating systems textbook. It's been long enough that I'm not in a position to make a current recommendation, unfortunately.
= Mike |