Memory problems with this loop
Hello again. I have a problem with the creation, loading and destruction of bitmaps.
The next loop consumes all the system memory until an error occurs .. Can not be done without this happening?
ALLEGRO_BITMAP *PRUEBA = NULL;
for (w2 = 0; w2 < 1000; w2++)
PRUEBA = al_create_bitmap(500, 333);
PRUEBA = NULL;
PRUEBA = al_load_bitmap("d:\\500.png"); // 500 x 333
This is just a test, but it is very important to adapt it to my program. Thank you
OK, a couple things happening here. When you call al_create_bitmap you are creating a bitmap in memory. The address of that new bitmap is then assigned to PRUEBA. After that you are re-assigning to PRUEBA the value of NULL, which means that the bitmap you created with al_create_bitmap is still dangling in memory and has not been freed.
After that, you are loading another bitmap with al_load_bitmap("d:\\500.png"); which 1) allocates space for a bitmap in memory and 2) initializes the values in that data to the contents in the 500.png file.
Then you are freeing the bitmap from memory that was allocated when you called al_load_bitmap by calling al_destroy_bitmap(PRUEBA);
(also, you can wrap your code in <code> tags </code> and it will look like below:)
Thread #617375. Printed from Allegro.cc
ok thanks, I understand, here there are plenty of al_create_bipmap and PROOF = NULL.
Your advice helped me a lot, I appreciate it.
My mind still thinks of gwbasic and msx-basic .. Regards