This error means you are allowing your emulator to use too much memory, relative to the amount your computer has or is using. To solve it, open your AVD manager, select the emulator and click Edit, and change the RAM to a smaller number.
See here : Failed to allocate memory: 8