• 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
Memory Warnings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory Warnings


  • Subject: Memory Warnings
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Wed, 08 Oct 2014 12:12:04 +0700

I have an app which sometimes receives: applicationDidReceiveMemoryWarning:.

Is there some rule, how much Ram use is ok? Like: not more than x KB, or: not more than y % of total Ram?

Is there a way for the app to find out how much memory it is currently using?

Is there a way for the app to find out how much memory e.g. an array of strings is using? (NSString might store the data in several formats: Utf-8, Utf-16 or whatever) + there might be some (hopefully small) overhead in both NSString and NSArray.

When I have a file of 100 KB and do:
	myData = [NSData dataWithContentsOfFile:options:error: ];
	myBytes = myData.bytes;
how much Ram am I now using? 100 KB or 200 KB? I.e. does "bytes" just return a pointer to some internal structure in NSData?

Would options = NSDataReadingMappedIfSafe be of some help?

Currently I am using (in a singleton class):
@property (nonatomic, strong) NSData	*myData;
- (NSData *)myData
{
	static dispatch_once_t justOnce;
	dispatch_once( & justOnce, ^{ _myData = [NSData dataWithContentsOfFile:options:error: ]; } );
	return _myData;
}

because several threads might need myData.

If I would (upon receiving a memory warning) release myData, I would never be able to get it back, would I?

How could I handle this case?

Gerriet.


_______________________________________________

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: Quincey Morris <email@hidden>
  • Prev by Date: Re: Questions on using a NSTextView as a source viewer.
  • Next by Date: Re: Memory Warnings
  • Previous by thread: Efficient CVPixelBuffer display in a CALayer
  • Next by thread: Re: Memory Warnings
  • Index(es):
    • Date
    • Thread