Memory Management on i.MX6 Android

Showing results for 
Search instead for 
Did you mean: 

Memory Management on i.MX6 Android

Memory Management on i.MX6 Android

System Memory Usage and Configuration


This document describes i.MX android memory usage, layout and configuration for the entire system.

Total DDR memory usage

When i.MX Android is running, the DDR memory will be used by the following components:

  • Linux Kernel reserved space, including:
    • kernel text, data section and initrd
    • kernel page tables
  • Normal zone space managed by kernel’s MM (high memory zone is also included)
    • Used by application by brk() or malloc() in libc
    • Used by kernel by mm api, like: kmalloc, dma_alloc, vmalloc
  • Reserved memory for GPU drivers, used by
    • GPU libs, drivers
    • Android surface view, normal surface buffers
    • VPUs working buffer and bitstream (we allocate the VPU buffer from GPU driver to make a unify method of allocation)

  • Reserved space for framebuffer BG triple buffers
    • Framebuffer display are always required to have triple and large buffers

Memory layout

The following diagram shows the default memory usage and layout on i.MX6Q/DL platform.


Memory configuration

According to different type of product and different hardware configurations (ddr size, screen resolution, camera), customer may do some configurations to the memory layout and usage to optimize their system. Some memory reservation can be configured by command line or modifying the code.

  • The kernel reserved space cannot be adjusted. It is controlled by the kernel and the Normal zone size and it depends on the total DDR size and the reserved spaces.
  • Reserved GPU memory size can be adjusted by adding "gpumem=" parameters in kernel commandline. It's size is highly depends on the screen resolution, the video stream decoding requirement and the camera resolution, fps.


  • Reserved memory size for BG (background) framebuffer can be configured by command line
fbmem=<fb0 size>,<fb2 size>,<fb4 size>,<fb5 size>

For example:

If you have two display devices, one is XGA LVDS, the other is HDMI 1080p device (default 32bpp), you have to specify the BG buffer size for them:


The size is calculated by xres*yres*bpp*3:

10M ~= 1024x768x4(32bpp)x3(triple buffer)

24M ~= 1920x1080x4(32bpp)x3(triple buffer)

Labels (1)
Tags (2)

Can we have more detailed memory breakdown for GPU reserved area?

My customer would like to reduce it as much as possible, even though user guide doesn't recommend it.

For doing this, he need to have generally how much memory is required for each component: GPU, VPU, and others.

Good docment!

Best basic knowledge for all

Can you please give us an example on how to calculate the VPU memory?  gpumem=???

I need to play 4 video streams 1920x1080 each. How do I calculate that?


Each Video stream 1920x1080x30FPS


*30FPS=62208000 pixels/s

*4 videos= 248832000 pix/s

if using RAW (3bytes x pixel)

Each video

RAW= 178 Mbytes/s

x4 videos: 711Mbytes/s

This is only the DDR used to decode,  DDR is also used to paint background and foreground framebuffers for display,  bytes are loaded into memory after decoding .

A single 30fps h264 full hd video can use 1090 MB/s of DDR if presented in a 60hz screen.


I use imx6DL on our device and the system hang happened randomly without any error logs or kernel panic.

After debugging for one month, we found if we increase the gpu reserved memory from 192M to 256M (described below), system is stable.

My question is, how should I know if the reserved GPU memory size is enough?

And, why there is no any error logs if the reserved memory is not enough?

(the resolution of panel we are using is 2400x1650)

static struct viv_gpu_platform_data imx6q_gpu_pdata __initdata = {

  .reserved_mem_size = SZ_128M + SZ_128M,


It is very hard to calculate exactly how much memory would be used by the GPU. But it is possible to make an approximation .

GPU would need memory to:

  • Store vertex
  • Store textures (this uses lots of memory)
  • Frame buffer Objects (FBO’s)
  • Command Buffer
  • Color and depth buffers
  • Caches

While most of the memory would be used by the FBO’s and the textures, the other items would add a few megabytes .

This could be a simple example:










  1. 17.4M

In this example the recommended value will be 32M,  consider that you might be using double or triple buffering, then multiply the FB values.


I want to decode 2 MPEG streams & combinely encode these into 1 H.264 stream. I calculated Frame buffers for 2 MPEG streams (VGA 640*480*30fps*2 Byte per pixel) = 18MB * 2 =36MB. For stable system, we need 128MB GPU & 128MB VPU. Kernel size is fixed ~13MB. Please advice whether it is correct? or still we need allocate memory for DMA.



Does the "gpumem=" kernel parameter work only if galcore is a module?

In my board I haven't galcore.ko so I guess it is compiled inside the kernel...and if I modify "gpumem" from uboot I cannot see any changes.

Hi Everyone,


We are trying porting a 480x272 LCD to our custom i.mx53 board.

This is our LCD structure in mxc_lcdif.c 


"0", 60, 480, 272, 111000, 2, 2, 2, 2, 41, 10,


We have tried part of this structure and it works on Linux, but when we use it on Android 4.2.2. and Linux 3.0.35, we see some errors like this: (logcat ouput)


I/SurfaceFlinger(15714): SurfaceFlinger is starting
I/SurfaceFlinger(15714): SurfaceFlinger's main thread ready to run. Initializing graphics H/W...
D/libEGL (15714): loaded /system/lib/egl/
D/libEGL (15714): loaded /system/lib/egl/
D/libEGL (15714): loaded /system/lib/egl/
W/imx5x.gralloc(15714): 32bpp setting of Framebuffer catched!
I/imx5x.gralloc(15714): using (fd=16)
I/imx5x.gralloc(15714): id = DISP3 BG
I/imx5x.gralloc(15714): xres = 480 px
I/imx5x.gralloc(15714): yres = 272 px
I/imx5x.gralloc(15714): xres_virtual = 480 px
I/imx5x.gralloc(15714): yres_virtual = 1088 px
I/imx5x.gralloc(15714): bpp = 32
I/imx5x.gralloc(15714): r = 0:8
I/imx5x.gralloc(15714): g = 8:8
I/imx5x.gralloc(15714): b = 16:8
I/imx5x.gralloc(15714): width = 203 mm (60.059113 dpi)
I/imx5x.gralloc(15714): height = 152 mm (45.452629 dpi)
I/imx5x.gralloc(15714): refresh rate = 33.30 Hz
I/hwcomposer(15714): <hwc_get_framebuffer_info,238> Vsync rate 33.299999 fps, frame time 30030030 ns
I/hwcomposer(15714): <hwc_device_open,276>
I/SurfaceFlinger(15714): Using composer version 1.0
W/SurfaceFlinger(15714): getting VSYNC period from fb HAL: 30030030
W/SurfaceFlinger(15714): no suitable EGLConfig found, trying without EGL_FRAMEBUFFER_TARGET_ANDROID
W/SurfaceFlinger(15714): no suitable EGLConfig found, trying without EGL_RECORDABLE_ANDROID
W/GraphicBufferAllocator(15714): WOW! gralloc alloc failed, waiting for pending frees!
W/GraphicBufferAllocator(15714): alloc(480, 272, 1, 00001a00, ...) failed -12 (Out of memory)
D/GraphicBufferAllocator(15714): Allocated buffers:
D/GraphicBufferAllocator(15714): 0x4167b668: 510.00 KiB | 480 ( 480) x 272 | 1 | 0x00001a00
D/GraphicBufferAllocator(15714): 0x4167b7e8: 510.00 KiB | 480 ( 480) x 272 | 1 | 0x00001a00
D/GraphicBufferAllocator(15714): Total allocated (estimate): 1020.00 KB
E/SurfaceFlinger(15714): GraphicBufferAlloc::createGraphicBuffer(w=480, h=272) failed (Out of memory), handle=0x0
E/BufferQueue(15714): [FramebufferSurface] dequeueBuffer: SurfaceComposer::createGraphicBuffer failed
F/libc (15714): Fatal signal 11 (SIGSEGV) at 0x00000020 (code=1), thread 15715 (SurfaceFlinger)
I/DEBUG ( 2350): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 2350): Build fingerprint: 'Freescale/imx53_smd/imx53_smd:4.2.2/1.1.0-rc3/eng.root.20170203.d2a45e2:eng/dev-keys'
I/DEBUG ( 2350): Revision: '1388577'
I/DEBUG ( 2350): pid: 15714, tid: 15715, name: SurfaceFlinger >>> /system/bin/surfaceflinger <<<
I/DEBUG ( 2350): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000020


Could you please share your advice about this problem?

Thanks & Regards,

Version history
Revision #:
1 of 1
Last update:
‎10-09-2012 10:30 PM
Updated by: