Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sujithkrishnan

macrumors 6502
Original poster
May 9, 2008
265
0
Bangalore
Hi all,

In my app, i am maintaining a huge 'catalogObject' which in turn contains some array of some other class objects...

However i archived the entire catalogObject and the archive file is around
688KB. That means my object is approx that size, isnt it??

But after running my app for somtime, its getting crashing...
and Application: didRecievedMemoryWarning is fired...

I just wanna know, what will b the default heap size for an app in device??

I made use of instruments (to see object allocation), and found that memory allocation is almost constant for a period of time (The application is crashing in this period).

However its sure that memory is insufficient....

Why so??? It should work with my obj of 1MB (max), isnt it?
 

Sbrocket

macrumors 65816
Jun 3, 2007
1,250
0
/dev/null
I just wanna know, what will b the default heap size for an app in device??

You shouldn't have to worry about that. Your application should behave completely correctly whether or not it runs out of memory. In other words, it should be able to handle didReceiveMemoryWarning: and release unnecessary objects that are allocated to bring down memory usage.

Big, centralized data sets being held in memory to me indicates lack of design forethought, though I'm not really sure what you're developing. Maybe you should look at caching the data in a file and loading what you need as you need it.
 

sujithkrishnan

macrumors 6502
Original poster
May 9, 2008
265
0
Bangalore
You shouldn't have to worry about that. Your application should behave completely correctly whether or not it runs out of memory. In other words, it should be able to handle didReceiveMemoryWarning: and release unnecessary objects that are allocated to bring down memory usage.

Big, centralized data sets being held in memory to me indicates lack of design forethought, though I'm not really sure what you're developing. Maybe you should look at caching the data in a file and loading what you need as you need it.

Okie...

But i am getting a black screen after i use my app for somtimes....
I read that we want to dealloc alll the instances and terminate the app when we get a memory warning... So hows the recovery is possible??

How we can terminate app programatically???
 

admanimal

macrumors 68040
Apr 22, 2005
3,531
2
Okie...

But i am getting a black screen after i use my app for somtimes....
I read that we want to dealloc alll the instances and terminate the app when we get a memory warning... So hows the recovery is possible??

How we can terminate app programatically???

You do not need to be responsible for terminating the app when you get a memory warning. You should just release as much memory as possible and if that still doesn't satisfy the OS, it will terminate the app.
 

Sbrocket

macrumors 65816
Jun 3, 2007
1,250
0
/dev/null
Okie...

But i am getting a black screen after i use my app for somtimes....
I read that we want to dealloc alll the instances and terminate the app when we get a memory warning... So hows the recovery is possible??

How we can terminate app programatically???

You're probably getting a "black screen" because views that do not currently have a parent at the time of the memory warning are released by the default behavior of UIViewController's didReceiveMemoryWarning method.

In these cases (when views are released), loadView is called on the view controllers that have been released when those views need to be displayed. If you didn't implement loadView: in your view controllers, then you need to.

App termination and other such things are handled by the OS, and are only done in cases where your application doesn't release enough memory when requested and keeps taking up more memory. If you're getting memory warnings a lot, chances are you need to look at the design of your application and tone down the memory usage a bit.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.