On Sunday, Mar 16, 2003, at 19:05 US/Pacific, Eric Grant wrote: Based on my experience with some simple test programs (under OS X 10.2.3), and confirmed by my skimming of the sources (Revision 1.1.1.4 of malloc.c), it appears that realloc does not "free" memory (in any meaningful sense) when passed a size smaller than the size originally malloc'd. That is, despite the supposed downsizing of the object, none of the logical address space encompassed by the original object is available to satisfy subsequent allocation requests. For example: p1 = malloc (2 * 1024 * 1024 * 1024); // 2GB p2 = realloc (p1, 1); The result is that half the logical address space has basically disappeared (though it appears to be available to satisfy a request to realloc p2 to a size up to 2GB). To my mind, this result violates the standard (from man realloc): The realloc() function changes the size of the previously allocated mem- ory referenced by ptr to size bytes. Moreover, it is difficult to see how this result is otherwise a "feature." Good? Bad? Ugly? None of the above? I'd say it was normal from my experience. Nothing violates the description you quote above, at any rate. AFAIK, this is the way most unices act for realloc, and in addition, address space acquired in the process of malloc()ing space is never returned. This is really a topic for darwin-developers, not darwin-kernel. The kernel just provides resources for user-mode operation, and it's user-mode that dictates policy (at least for this issue). Regards, Justin -- Justin C. Walker, Curmudgeon-At-Large * Institute for General Semantics | Some people have a got a mental | horizon of radius zero, and call | it their point of view | -- David Hilbert *--------------------------------------*-------------------------------* _______________________________________________ darwin-kernel mailing list | darwin-kernel@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-kernel Do not post admin requests to the list. They will be ignored.
participants (1)
-
Justin Walker