ALLEGRO_VIDEO_BITMAP using more RAM than ALLEGRO_MEMORY_BITMAP
Turbine

I'm not sure whether this is a bug or a lack of understanding on my part.

I believe setting the flag for newly created bitmaps 'ALLEGRO_MEMORY_BITMAP' should store the bitmap in system memory. 'ALLEGRO_VIDEO_BITMAP' should store the bitmap into video memory, which should use less system memory?

The amount of RAM consumption is:
ALLEGRO_VIDEO_BITMAP: 80,292k
ALLEGRO_MEMORY_BITMAP: 9,420k

Test:

    ALLEGRO_BITMAP* b;
    al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP);
    for(int i = 0; i < 100; i++)
       b = al_create_bitmap(255, 255);

    ALLEGRO_BITMAP* b;
    al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
    for(int i = 0; i < 100; i++)
       b = al_create_bitmap(255, 255);

Also this causes the program to crash, just 16 with alpha: al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_16_WITH_ALPHA);

Elias

It might be that your graphics drivers keep another copy. Can you check how much of the RAM is allocated in your program, in the Allegro DLL, and by the operating system? Also some graphics chips can use shared memory so whatever is allocated in video RAM counts as normal RAM.

If your using the DirectX driver, you could try using the ALLEGRO_NO_PRESERVE_TEXTURE flag and restoring your bitmap whenever you get an ALLEGRO_EVENT_DISPLAY_LOST event. It may cause Allegro to drop one extra copy of the bitmap. Otherwise with DirectX you have three copies: The one Allegro keeps to restore the bitmap whenever the display is lost, the copy your graphics driver keeps, and the copy in (possibly shared) video card memory.

[edit:] In addition to all of that, the operating system will usually not free memory immediately but only at the end of the program. So even if Allegro and graphics drivers only make a temporary copy of the bitmap it can stay allocated until the program ends.

Turbine

Thanks for your reply, It's incredible to think such a massive difference of memory is used despite it possibly using shared memory. Would have thought the 512mb of dedicated video memory would have been used first.

Also is it possible to use the DirectX driver for 2D? Can't find any mention for this, only Direct3D.

Jonatan Hedborg

What's the bit depth of the bitmaps you are creating? 255*255*100*4 (32 bpp) should be 26MB minimum.

Thomas Fjellstrom
Turbine said:

Would have thought the 512mb of dedicated video memory would have been used first.

If its actually dedicated, it will be.

Turbine

Yes, it actually is.

510mb dedicated with 730mb shared memory.

@What's the bit depth of the bitmaps you are creating?
I tried 16bit with no alpha and that took up 50mb.

Thread #608039. Printed from Allegro.cc