On Wednesday, August 6, 2003, at 1:24 PM, Stiphane Sudre wrote: Note that it panics if retval is *different* from KERN_RESOURCE_SHORTAGE". So in case of KERN_RESOURCE_SHORTAGE, whatever comes below will be executed. Correct. The issue is that most kernel code expects zalloc() to wait until memory is available. They only expect a NULL return in the cases that they specified that they are unwilling to block for memory allocation. However, one of the "different from KERN_RESOURCE_SHORTAGE" errors actually occurs as a result of the kernel's virtual address space being exhausted (rather than just being short of free page frames at the moment). It is extremely unlikely that this "exhausted virtual memory space" situation will rectify itself by having the current thread wait. So we panic. This is somewhat analogous to malloc(). It will normally wait for memory to become available (including waiting for the kernel to select and page out other application pages, etc...). But if the virtual address space of your application is completely exhausted, there's not much that can be done. The good news is that the Darwin 10.7 (Panther) PowerPC[1] kernel supports a significantly larger kernel virtual address space. So the odds of hitting that panic go WAY down (most existing machines can't handle enough physical memory to trigger it). There are also additional hand and soft resource limits added to keep applications from inducing run-away kernel allocations. Side question: Is there a way or a tool to monitor kernel memory (free) space? Well, free space is a bit tough to track - especially since the kernel carves its own address space up into a few large submaps. One of those is the zones submap (where all the zones virtual memory allocations reside). You can see what allocations have been made in there by using the zprint(1) utility. But I'm pretty sure that only the kernel debugger will let you see what the maximum size of the submap is - to allow you to compute the remaining free space. --Jim _______________________________________________ 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.