• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: memory warnings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memory warnings


  • Subject: Re: memory warnings
  • From: John Stiles <email@hidden>
  • Date: Wed, 12 Mar 2008 11:00:16 -0700

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


  • Follow-Ups:
    • Re: memory warnings
      • From: Jens Alfke <email@hidden>
    • Re: memory warnings
      • From: Alexander Cohen <email@hidden>
References: 
 >memory warnings (From: Alexander Cohen <email@hidden>)
 >Re: memory warnings (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: Setting the badgeValue in ToolbarItem in ViewController file.
  • Next by Date: Re: memory warnings
  • Previous by thread: Re: memory warnings
  • Next by thread: Re: memory warnings
  • Index(es):
    • Date
    • Thread