370

From today, when I tried to run an app in NetBeans on a 2.3.3 Android platform, it shows me that:

Failed to allocate memory: 8

This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

and the Emulator doesn't want to start.

This is for the first time when I see it, and google has no asnwers for this, I tried even with 2 versions of NetBeans 6.9.1 and 7.0.1, still the same error.

Kara
  • 6,115
  • 16
  • 50
  • 57
Denees
  • 9,100
  • 13
  • 47
  • 76
  • 3
    Just curious why you're using NetBeans vs Eclipse. I use NetBeans for other things (namely php), but have just found it easier to use eclipse for android stuff. What in your opinion are the benefits over eclipse? – SBerg413 Aug 28 '11 at 19:12
  • 3
    I just never used Eclipse before, but I don't know why, I hate it, the reason, it's even complicated in GUI vs NetBeans, but for the moment I am downloading it, to try, if the problem disappears, I will make Android stuff only in it. – Denees Aug 28 '11 at 19:32
  • 48
    Wow, that comment was a comma massacre. Anyway, make sure your AVD is using an appropriate amount of RAM (i.e., enough to run but not more than your computer can handle). This is set when you create the virtual device. – Glendon Trullinger Aug 28 '11 at 19:52
  • Lol for the comment, but thanks, I figured it out. The problem was in the amount of ram I had specified for the virtual machine, and it was 1024MB, now I have 512MB and it is ok, now I need to find how to improve this amount of ram, 512 is not so much, and the machine is a little bit laggy. BTW, you can answer as normal answer and I'll mark as the answer for the question ;) – Denees Aug 28 '11 at 20:02
  • 2
    Just for reference, I have a Core i7 with 16gb of ram, maxxed out ram on my AVD's and they are all laggy unfortunately :/ – Jack Aug 28 '11 at 20:35
  • 1
    I have a Windows 8 64bit machine running on an Intel core i7 processor. I had to change ram settings for this AVD (Nexus 7) down to 512mb in order for it to run. – IgorGanapolsky Dec 30 '13 at 20:36
  • On a different, but related, question, someone mentioned something called Glary Utilities. There is a memory optimization utility in the suite that recovers memory marked as Available (in Windows) back to the Free state. I tried it and it worked for me. Basically, if you check the amount of Free memory (not the little bar but the actual amount next to the word Free in Task Manager), it is likely less than the amount you are requesting for your emulator. Get this number increased and see if your emulator starts with the desired size. – Newclique Mar 11 '14 at 20:17
  • I have ADT v22.6.3. I was creating AVD with skin WXGA800 with 10.1" device. When I changed skin to "skin with dynamic hardware controls", it worked for me. – Swaroop May 19 '14 at 10:39
  • I give the RAM:500 and still emulator does not load could anyone tell what the reason would be@GlendonTrullinger – user285oo6 Jul 01 '14 at 11:01

20 Answers20

373

I figured it out. The problem was in the amount of ram I had specified for the virtual machine, and it was 1024MB, now I have 512MB and it is ok, now I need to find how to improve this amount of ram, 512 is not so much, and the machine is a little bit laggy.

Denees
  • 9,100
  • 13
  • 47
  • 76
  • 20
    I have the same issue with this. I have 8GB of RAM on my machine, with 6GB sitting free while the Android emulator tells me that it can't allocate 1GB? – Strozykowski Nov 11 '11 at 01:38
  • 5
    I have as well 8GB of Ram, but SDK tells me that I can't use it more than 512 :) – Denees Nov 11 '11 at 07:13
  • Might have something to do with the Max Java Heap Size or process size or whatever its called. – Faizan Kazi Mar 15 '12 at 23:28
  • Doesn't work, I've tried setting RAM size to 256 and still got the same error message... – Egor Jul 19 '12 at 10:16
  • 5
    One more fix to add. Sometimes, setting RAM to lower values doesn't work. It that case, try to launch emulator from commandline with something like `emulator-x86 -avd ` – Mykhailo Gaidai Jul 20 '12 at 07:35
  • Still I have problem .I have followed all the way as you have described but not getting reason of this problem. My System Configuration is : Windows 7 , 4GB RAM. Emulator configuration : Android v4.0 , 512MB RAM, Heap size - 48. – Nirav Shah Sep 28 '12 at 09:04
  • 14
    Just got the solution : need to specify AVD resolution forcefully : 800 x 1280. It starts my AVD as what I required – Nirav Shah Sep 28 '12 at 09:14
  • 4
    The problem comes from any display skin that adds a value of 1024 to `hw.ramSize` in the config.ini (`Device Ram Size` in the Hardware list of the GUI). Make sure to either select a "skin" that has a lower value, or to use a manual resolution and to remove this line from the Hardware list - you can't remove it when a skin is selected. – RedGlyph Nov 02 '12 at 11:49
  • 3
    1024 didn't work, 768 did. Running on a 16G machine with 10G free. – Markus Junginger Dec 19 '12 at 13:55
  • 1
    On windows it can't creates the reference for memory if it is bigger than 768, even if you have more than 8GB RAM. – Hussain KMR Behestee Aug 29 '13 at 07:36
61

Referring to Android: failed to allocate memory and its first comment under accepted answer, changing "1024" to "1024MB" helped me. Pathetic, but works.

Community
  • 1
  • 1
Fenix Voltres
  • 3,448
  • 1
  • 29
  • 36
  • 29
    'MB' is not recognized by the emulator, forcing it to use the default 256 MB value. Be aware that the amount you specify is not what you will get! – RedGlyph Nov 02 '12 at 10:58
  • 1
    Looking under Apps, Runnning, lists the total amount of memory to approx 240MB, so it seems as it reverts to 256 MB. – jishi Nov 09 '12 at 10:47
  • Add in Run Configurations window the parameter -memory 512 from this link fixed it for me – GatesReign Dec 03 '12 at 15:14
43

In my case:

  • Using built in WXGA720 to simulate 720p device, always got this error
  • Manually set AVD resolution to 720 x 1280, works for me

hope it helps~

RRTW
  • 3,160
  • 1
  • 35
  • 54
30

Everything else you read here and elsewhere is pure conjecture. The only sure-way to fix this problem is vote for this bug report.

The problem isn't related to emulator resolution or OpenGL, nor how much memory your computer has. I've got 24GB memory in my computer and most of the time I run with hw.ramSize=1024 I get error 8. Other times it works just fine without any configuration changes. I hope you caught that: I did not alter the emulator configuration at all and yet sometimes it runs and sometimes it fails.

There is a high probability it has something to do with memory fragmentation. I recommend reducing the value of hw.ramSize as a temporary workaround.

user229044
  • 232,980
  • 40
  • 330
  • 338
Gili
  • 86,244
  • 97
  • 390
  • 689
  • 2
    With all respect, your answer is pure conjecture as well; For me, I have no issue running any emulated device with virtual RAM set as high as 2048 (I didn't try any higher). However those devices will only run when I access my machine through **Remote Desktop**. So for me, it's certainly a graphics issue and not a memory fragmentation issue. I can reliably prove this by jumping my session back and forth between local and remote. Same session, same instance of AVD manager, just no terrible NVIDIA cards and their godawful drivers in one scenario. (But that's a rant for another thread). – s.co.tt Oct 23 '13 at 03:07
  • If it's "RAM fragmentation" we could probably test that using one of those silly free "RAM defragmentation" programs, right? – User Aug 03 '15 at 19:01
29

Works with 512 Mb instead. None of the above methods works for me.

slash33
  • 899
  • 1
  • 11
  • 17
  • The "Failed to allocate memory: 8" error disappeared after reducing the RAM size from 1024 to 768 Mib. – curd0 Dec 29 '12 at 23:22
  • many of them are telling the same thing to fix the size of 512 MB.But it wasn't worked at all – Stephen Apr 01 '14 at 10:47
17

Looks like there are a thousand different fixes for this...none of the above worked for me, but what worked was to launch the AVD from the command line emulator-arm.exe @AVD-NAME

Somehow if launched with only emulator.exe, I would get the same error message than when trying to launch via Eclipse.

Vincent Demers
  • 145
  • 1
  • 5
  • You might have the same issue as me. The DLL files get loaded when you start the emulator from one place and not if you start from another. – mjaggard Oct 04 '12 at 09:53
14

I realized the solution to this problem stems from Eclipse memory allocation when you run the application in normal mode. I just checked the "Run as Administrator" box under the shortcut properties for Eclipse and now it allows me to allocate more memory for the AVD.

Hope that helps.

Mahan H
  • 153
  • 1
  • 4
13

I have overcome this problem by changing the device screen size.

I have found that if you are specifying 1024 mb ram then you have to specify the device screen size in hdpi only and if it is 512 mb ram then it should be mdpi or others.

So, We can clearly say that ram size should be specify according to the screen size . If you are specifying the 1024 ram size while keeping the device screen size in mdpi then it results in the above mentioned error i.e "Failed to allocate memory: 8 This application has requested the Runtime to terminate it in an unusual way.

Please contact the application's support team for more information."

or

make your options in AVD manager as follows:

[2013-01-11 14:44:01 - SDK Manager] hw.sensors.orientation=yes

[2013-01-11 14:44:01 - SDK Manager] hw.camera.front=none

[2013-01-11 14:44:01 - SDK Manager] hw.gps=yes

[2013-01-11 14:44:01 - SDK Manager] skin.dynamic=no

[2013-01-11 14:44:01 - SDK Manager] hw.keyboard=no

[2013-01-11 14:44:01 - SDK Manager] vm.heapSize=32

[2013-01-11 14:44:01 - SDK Manager] hw.ramSize=343

Kanwaljit Singh
  • 4,339
  • 2
  • 18
  • 21
Vsw10
  • 143
  • 3
  • 10
  • This worked:[2015-07-23 12:54:59 - SDK Manager] disk.dataPartition.size=500M [2015-07-23 12:54:59 - SDK Manager] hw.gpu.enabled=yes [2015-07-23 12:54:59 - SDK Manager] hw.audioInput=yes [2015-07-23 12:54:59 - SDK Manager] hw.sensors.orientation=yes [2015-07-23 12:54:59 - SDK Manager] hw.camera.front=none [2015-07-23 12:54:59 - SDK Manager] hw.gps=yes [2015-07-23 12:54:59 - SDK Manager] skin.dynamic=no [2015-07-23 12:54:59 - SDK Manager] hw.keyboard=yes [2015-07-23 12:54:59 - SDK Manager] vm.heapSize=32 [2015-07-23 12:54:59 - SDK Manager] hw.ramSize=512 – user914425 Jul 23 '15 at 19:55
6

I went through all the other solutions mentioned on this thread and didn't find anything that was working so I dinked around a little. The Google version of the API was failing on me for some reason. I changed it back to the vanilla and no more crashes.

I must have some other issue but maybe this will help somebody...

Helico
  • 51
  • 1
  • 1
  • Odd. I was set to the vanilla version, but switching it to the Google API solved it. +1 for the idea anyways! – Paul Oct 03 '12 at 15:53
6

Have a look at the official issue 33930. There is pointed out, that it may have to do with the start up of OpenGL during the start of the emulator. Others wrote it only crashes when they use WXGA800-skin and suggest to manually set the resolution to 800x1280.

Further there are ZIP-files provided to manually downgrade your android SDK to version 19 and plattform-tools to version 11. This may help as well to temporally fix the issue.

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
Max
  • 51
  • 1
  • 1
  • This might be related to my issue. The DLL files get loaded when you start the emulator from one place and not if you start from another. – mjaggard Oct 04 '12 at 09:52
  • There must be more to it. First setting it to WXGA800 then changing it to a manual resolution of 1280x800 still crashes AVD. Only removing the `hw.ramSize=1024` solves the issue (you can't do that if WXGA is selected, you need to use a manual resolution settings). – RedGlyph Nov 02 '12 at 11:00
5

I change my monitor DPI settings from the launch options of AVD and synchronized it with the original and current setting of my monitor, and it worked.

Josh Darnell
  • 11,304
  • 9
  • 38
  • 66
Droid GEEK
  • 192
  • 2
  • 11
5

I have 16 GB and a 3.4 Ghz quad core proc in my machine. The virtual machine won't let me run it at 1024 either. I did bump it up to 878MB because it failed at 880 with the same message. This seems to be the most ram I can allocate to the emulator. It is still slow but I'm assuming it is better than 512MB.

sondlerd
  • 1,025
  • 1
  • 10
  • 15
4

I solved by put as storage size 2 times the RAM size, and by putting the SD storage size the same as RAM size.

Francesco Belladonna
  • 11,361
  • 12
  • 77
  • 147
3

I had the same issue but before I got the issue it asked me to capture a video source.

I disabled the camera support and I was able to use 1024MB of RAM.

Using Windows 64bit, Xoom (Android 3.0).

Lucifer
  • 29,392
  • 25
  • 90
  • 143
3

In my case, changin screen resolution from WVGA720 to WSVGA works for me.

Mabicho
  • 31
  • 1
3

The problem is in memory fragmentation. OS have to allocate all the ram you specified for vm ( say 1Gb) as one continuous block. Sometimes there is no such block. To fix it close running programs, then run avd and start your virtual machine.

Dave
  • 356
  • 1
  • 7
2

What worked for me on Windows was:

1) Closing Eclipse 2) Running Avd UI 3) Closing all running processes, especially ones that are heavy in memory, like Chrome, explorer.exe, etc 4) Start the emulator 5) Win

Oren Bengigi
  • 994
  • 9
  • 17
2

Be sure that IntelHAXM is installed correctly. It's not enough to download and "install" it through the SDK Manager. You need to manually install it from:

android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager

Also, be sure that Intel Virtual Technology is enabled in your BIOS.

Follow the guide on developer.android.com or Intel's installation instructions.

Community
  • 1
  • 1
pegel
  • 162
  • 1
  • 4
2

You only need to edit your virtual device's ram, making it lower! Try 20 MB, and it will work!

1

I noticed it was related to just one avd all the rest of the ones I have worked fine. I deleted it and created a new one and now it works.

Jason Crosby
  • 3,533
  • 4
  • 28
  • 49