iPhone app uses 60mb of virtual memory on startup - iphone

Now, I know my app uses a lot of graphics, but not 60mb of graphics. However, Instruments shows me that the app is using 60+mb of virtual memory just after startup. The compiled app is 24mb big, and we're talking about the idle welcome screen after startup; any idea why the VM size might be this huge?

The virtual memory is the address space allocated by your app from calls like malloc. This does not mean that it uses this much physical memory. For example, all libraries (libSystem, ...) that your app links to are allocated in shared memory, which is part of your virtual memory.
A good explanation of memory types can be found in the help of the "Activity Monitor" application. There's also a great blog post from Mike Ash.

How/when are you loading your image?
I'll take a guess and say that 60MB is the size of your app with uncompressed images.

Related

How to monitor how much memory my App is consuming?

From time to time, different Apps I am developing close itself, I'm assuming it is because of memory usage that the IOS kills once it is to high.
Even if it is not because of memory I will like to find out how much memory my app is consuming every step of the way.
Update:
Thanks guys, I understand Instruments purpose, but my Idea was to monitor memory while I am using the app not connected to the computer. For instance, something like placing a UILabel Text content with the current memory consumption.
Any directions?
Apple Instruments User Guide is a good way to start. There is a chapter devoted to locating memory issues. To monitor memory consumption, Allocations, Leaks and Activity Monitor instruments will be most helpful.
Let's using instrument to profile your application. Using Allocation mode, you can find out :
- how much memory your app using.
- how many objects of your app are allocated in memory.
- Which objects (GUI, NSOBjects, bla bla bla) are allocated in memory.
- Your app using more or less memory after you do somethings in your app.
More detail:
https://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Introduction/Introduction.html
Use 'instruments'. Run -> Profile

Maximum size of document directory in Iphone?

I need to store images and videos in document directory,So i want to know that maximum how much data i can store in document directory that it will not give me memory warning.
Can anyone tell me maximum data storage possible for document directory in Iphone?
I think there is no limit to the size of your sandbox other than the
remaining capacity of the device itself.
According to apple..
To manage program memory, iPhone OS uses essentially the same virtual
memory system found in Mac OS X. In iPhone OS, each program still has
its own virtual address space, but (unlike Mac OS X) its usable
virtual memory is constrained by the amount of physical memory
available. This is because iPhone OS does not write volatile pages to
disk when memory gets full. Instead, the virtual memory system frees
up volatile memory, as needed, to make sure the running application
has the space it needs. It does this by removing memory pages that are
not being used and that contain read-only contents, such as code
pages. Such pages can always be loaded back into memory later if they
are needed again.
If memory continues to be constrained, the system may also send
notifications to the running applications, asking them to free up
additional memory. All applications should respond to this
notification and do their part to help relieve the memory pressure.
For information on how to handle such notifications in your
application, see “Observing Low-Memory Warnings.”
so there is no size limit as such...
The links bellow may be of some help:
http://www.iphonedevsdk.com/forum/iphone-sdk-development/4083-limit-restrictions-filesize-filecount-app-folder.html
https://discussions.apple.com/message/7599983?messageID=7599983#7599983?messageID=7599983

iPhone and iPad App Real and Virtual Memory usage

I've been trying to keep my iOS Apps memory footprint nice and low, however, I'm not really sure what a good threshold is for either real or virtual memory is iOS.
At the moment a very simple app is using 12MB real memory and 70MB virtual memory but this is going to increase as my app becomes more complex.
My question is, what are the real and virtual memory levels that I should try to keep below to avoid getting memory warnings?
I realise that this is not an exact science as there are other factors like the memory footprint of other apps on the system but a rough answer would be welcomed.
This is indeed not at all an exact science. In my experience it's at least as important to release enough memory immediately when receiving an OS request to do so as it is to keep memory low.
That being said, as long as I keep my apps under ~80 MB real memory on an iPad I typically don't get any warnings (for refernce, iPad 1 has 256MB). (keep in mind, this is the full memory used, including screen buffers etc. allocated by the OS for your app, not just what you allocated yourself)

available RAM iPhone app

how do i increase the available memory (more concrete: the part of the RAM) that can be used by my app?
i am not referring to the space available on the harddisk of an iphone, but to the RAM.
does anyone know if there's a way to use the whole free part of the RAM for my app only?
i have to clear this up a bit, sorry if it was too vague:
i had to think of the java heap size, which can be increased by adding a parameter to the startup command of the java programming.
as i don't know, but at the moment suppose on the iphone something similar happens (every app has just xxMB RAM for execution) this value might be adjustable, so that i can use the whole remaining RAM for my app.
which pretty much is what i need for this special app (non-app-store-publication; file-sizes between 50MB and several 100MB)
How do i increase the available memory?
Short answer: you don't.
Memory is managed by the kernel.
Your application process can't control this.
You can't explicitly control this - this is managed by iOS.
You can't do that. Try reducing your memory usage instead of looking for ways to remove well needed limits.
Store your data instead and read from it when needed.
I don't know for sure if you can configure RAM allocated for your app. I think that is taken care of by the iOS kernel
It's unlikely (read: not going to work) that you will be able to allocate anything more than a few Mb in your application at once.
Not planning on publishing your app to the App Store won't change this. Apple don't officially acknowledge the amount of memory in iOS devices. But its known that devices have between 128Mb and 512Mb of physical RAM.
With the kernel, essential applications (Phone app, etc), background processes, etc, you won't have anything like that available to your application. Careful analysis in instruments would suggest that you'll generally start getting memory warnings when you've allocated around 22Mb of RAM in your application.
A change made in iOS 5 makes the watchdog process much more aggressive with killing applications after you get a memory warning. If you get a memory warning on iOS5 you have to reduce your memory usage or you will get jettisoned by the OS.
If you want to proceed, you will have to figure out how to reduce the amount of memory your datasets require. Its unlikely that all of the 100Mb file needs to be in memory at once. iOS devices have "relatively" fast CPU's and storage, you'll have to architect your application to read and write to storage in chunks and work on smaller subsets of your data.
Some related Stackoverflow questions and links:
Monitor memory usage in an iphone app?
How much memory can an iPhone app use?
10 iPhone Memory Management Tips

What is the maximum sandbox size on iPad?

I'm writing an iPad app that acts as a media player (video and photos). I know there is a 2GB size limit on apps, however is this the size limit on an app when downloaded? Or the limit on the size of your sandbox throughout the life of the app? For example what if my small app later on downloads various media files to its sandbox that put the user over 2GB total (app + downloaded media)?
Thanks!
There is no limit to the size of your sandbox other than the remaining capacity of the device itself.
I did a little test last night, and my sandbox was over 8 GB when I finally called it quits.
Sandbox size is unlimited, According to the iPhone Application Programming guide:
To manage program memory, iPhone OS uses essentially the same virtual memory system found in Mac OS X. In iPhone OS, each program still has its own virtual address space, but (unlike Mac OS X) its usable virtual memory is constrained by the amount of physical memory available. This is because iPhone OS does not write volatile pages to disk when memory gets full. Instead, the virtual memory system frees up volatile memory, as needed, to make sure the running application has the space it needs. It does this by removing memory pages that are not being used and that contain read-only contents, such as code pages. Such pages can always be loaded back into memory later if they are needed again.
If memory continues to be constrained, the system may also send notifications to the running applications, asking them to free up additional memory. All applications should respond to this notification and do their part to help relieve the memory pressure. For information on how to handle such notifications in your application, see “Observing Low-Memory Warnings.”
IIRC, Apple limits size of d/led applications to 20MB.