Re: memory warnings
Re: memory warnings
- Subject: Re: memory warnings
- From: Alexander Cohen <email@hidden>
- Date: Wed, 12 Mar 2008 14:05:32 -0400
Thanks, ill look into this. Its much better than nothing.
AC
On 12-Mar-08, at 2:00 PM, John Stiles wrote:
You can dive into BSD to get some values which might help you.
vm_statistics vmstats;
mach_msg_type_number_t count;
kern_return_t result = host_statistics(mach_host_self(),
HOST_VM_INFO, (host_info_t) &vmstats, &count);
uint64 freeMem = uint64(vmstats.free_count +
vmstats.inactive_count) * uint64(vm_page_size);
I am not 100% sure if this will work for you, since it's been a
while since I've looked at this stuff, but it's worth experimenting
with. It might be telling you about physical RAM, not process
address space, which are both interesting but have different failure
modes (VM thrashing, failures in malloc).
Nick Zitzmann wrote:
On Mar 12, 2008, at 11:40 AM, Alexander Cohen wrote:
Is there any way to be notified when my app is running low on
memory?
Not really.
My app is very memory intensive and needs to have a lot of images
in memory at the same time, id like to be able to clear some cache
if memory gets too low.
If you're using Leopard, then consider releasing a 64-bit version
of your application.
If you're using Tiger, then consider using the NSZone API with
zones that will not grow (zero granularity). Then, if object
allocation isn't working, then at least your app won't crash.
Either way, if your app creates lots of temporary objects, then you
should wrap them in NSAutoreleasePools.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden