PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Memory useage

Is it possible to know how much memory a CGapiSurface class use at any moment, including it's surface, bitmap, data, etc?

Thanks!
Hi,

Sure. Take a look at the member variables of CGapiSurface. You can calc the size of the member variables just by looking at the structs.

The internal buffer of each surface is always stored as DWORD-aligned WORDS in both x/y direction. For example, if you create a surface with width dwWidth and height dwHeight, what is allocated is:

Code:
long xSurfacePitch = (dwWidth+1) & 0xfffe; // words per line, dword-aligned
long ySurfacePitch = (dwHeight+1) & 0xfffe; // words per line, dword-aligned
m_surface.dwSize = xSurfacePitch*ySurfacePitch;
m_surface.pSurface = (WORD*) ::LocalAlloc(LMEM_FIXED, (m_surface.dwSize << 1));


The bitmap used to create surfaces is always discarded after it has been used, and is not stored permanently.

/Johan