What Is the Maximum Amount of Ram an App Can Use

What is the maximum amount of RAM an app can use?

What is the maximum amount of memory (in Megabytes / as percentage of the total RAM) that an Android application (that is not a system app) can use?

That varies by device. getMemoryClass() on ActivityManager will give you the value for the device your code is running upon.

Are there any differences between the Android versions?

Yes, insofar as OS requirements have increased over the years, and devices have to adjust to match.

Are there differences concerning the manufacturer of the device?

Yes, insofar as manufacturers manufacture devices, and the size varies by device.

Which "side factors" are taken into consideration when it comes to determining how much RAM an app can use?

I have no idea what "side factors" means.

Early devices had a per-app cap of 16MB; Later devices increased that to 24MB or 32MB

That's about right. Screen resolution is a significant determinant, as larger resolutions mean larger bitmaps, and so tablets and high-resolution phones will tend to have higher values yet. For example, you will see devices with 48MB heaps, and I wouldn't be surprised if there are values higher than that.

How is it possible that apps exceed that limit?

You assume that the author of that app knows what (s)he is doing. Considering that memory usage of an app is difficult for a core Android engineer to determine, I would not assume that the app in question is necessarily providing particularly accurate results.

That being said, native code (NDK) is not subject to the heap limit. And, since Android 3.0, apps can request a "large heap", usually in the hundreds of MB range, but that's considered poor form for most apps.

Furthermore, I noticed that some apps of mine crash with an OutOfMemoryException when using around 30-40 Megabytes.

Bear in mind that the Android garbage collector is not a compacting garbage collector. The exception really should be CouldNotFindSufficientlyLargeBlockOfMemoryException, but that was probably deemed too wordy. OutOfMemoryException means that you could not allocate your requested block, not that you have exhausted your heap entirely.

The maximum amount of memory any single process on Windows can address

Mark Russinovich published a multipart series on windows memory resources really covers this very well. You can find it here:
http://blogs.technet.com/b/markrussinovich/archive/2008/07/21/3092070.aspx

He covers the reasons why the limits are what they are, as well as tests. The code for the tests are floating around in the tubes somewhere.

If you want to know about memory resources and the problems you can see from leaking the various types, it is a good read.

But, in a nutshell, 32 bit on 32 bit OS: 2 GB, unless set to large address space aware, in which case 3 GB. 32 bit on 64 bit OS: 2 GB, unless set to large address space aware, in which case 4 GB.

64 bit process: 2 GB, unless set to large address space aware, in which case it could address up to 8 TB, unless it is hosted on an Intel Itanium-based systems which is limited to 7 TB.

Microsoft states the various limits (by flavors and types) at:
http://msdn.microsoft.com/en-us/library/aa366778.aspx

How much RAM C# application can use?

64 bit application, including managed ones, can access large memory.

32 bit application have a virtual address space of maximum 4GB. In practaice they get 2GB by default. /LARGEADRESSAWARE applicaitons can get 3GB with /3gb in boot.ini or 4GB when running on WoW64.

Managed application, even on x64 cannot allocate any single object larger than 2GB. Including arrays.

But no matter the amount of VA available at your disposal: manipulating a +2GB DataTable object is just not going to work. Use a storage engine capable of handling and manipulating large amounts of data fast, and capable of intelligent paging. Redis, Cassandra or even traditional RDBMSs are more suited for the job.

Even if you decide to manipulate the data directly in memory, you need a smarter format than DataTable.

How much memory can a 32 bit process access on a 64 bit operating system?

2 GB by default. If the application is large address space aware (linked with /LARGEADDRESSAWARE), it gets 4 GB (not 3 GB, see http://msdn.microsoft.com/en-us/library/aa366778.aspx)

They're still limited to 2 GB since many application depends on the top bit of pointers to be zero.

What is the maximum amount of RAM an app can use?

What is the maximum amount of memory (in Megabytes / as percentage of the total RAM) that an Android application (that is not a system app) can use?

That varies by device. getMemoryClass() on ActivityManager will give you the value for the device your code is running upon.

Are there any differences between the Android versions?

Yes, insofar as OS requirements have increased over the years, and devices have to adjust to match.

Are there differences concerning the manufacturer of the device?

Yes, insofar as manufacturers manufacture devices, and the size varies by device.

Which "side factors" are taken into consideration when it comes to determining how much RAM an app can use?

I have no idea what "side factors" means.

Early devices had a per-app cap of 16MB; Later devices increased that to 24MB or 32MB

That's about right. Screen resolution is a significant determinant, as larger resolutions mean larger bitmaps, and so tablets and high-resolution phones will tend to have higher values yet. For example, you will see devices with 48MB heaps, and I wouldn't be surprised if there are values higher than that.

How is it possible that apps exceed that limit?

You assume that the author of that app knows what (s)he is doing. Considering that memory usage of an app is difficult for a core Android engineer to determine, I would not assume that the app in question is necessarily providing particularly accurate results.

That being said, native code (NDK) is not subject to the heap limit. And, since Android 3.0, apps can request a "large heap", usually in the hundreds of MB range, but that's considered poor form for most apps.

Furthermore, I noticed that some apps of mine crash with an OutOfMemoryException when using around 30-40 Megabytes.

Bear in mind that the Android garbage collector is not a compacting garbage collector. The exception really should be CouldNotFindSufficientlyLargeBlockOfMemoryException, but that was probably deemed too wordy. OutOfMemoryException means that you could not allocate your requested block, not that you have exhausted your heap entirely.

32 bit applications memory limit on a 64 bit OS (Windows)

Processes do not need to use the same address space. That means multiple 32-bit applications running simultaneously can effectively use all the memory available on a 64-bit machine.

how to find the maximum limit of Memory Allocation in c

malloc() is allowed to fail, in which case it returns a NULL-pointer without allocating any memory. It is always an all-or-nothing allocation. It either succeeds and allocates a full chunk of memory of the requested size, or it fails, returning a NULL-pointer without allocating a single byte.

As for knowing how much memory is available - that really depends on the environment: what OS are you running this in, is that a 16-, 32-, 64-bit memory architecture?

For instance, if you are running on Windows 10 you can use the GlobalMemoryStatusEx() facility (refer to MSDN:GlobalMemoryStatusEx() for details).

Linux, OTOH, provides a neat sysconf() way of retreiving similar information. Refer to this page for more details.

Even if your OS is 64-bit that wouldn't necessarily mean that your application can access more than a certain limit. For instance Windows 7 64-bit will only let you address up to 8GB of memory in your application code even though the full virtual memory space is 16TB.



Related Topics



Leave a reply



Submit