|
Bitmap loads then goes NULL after x iterations |
Travis Peterson
Member #16,756
October 2017
|
Loading bitmap with and it loads then after about 100 seconds it breaks saying abort() and clicking retry break in VS shows the error is thr textBox pointer is 0x0000000.. NULL What could cause this? |
Chris Katko
Member #1,881
January 2002
|
Is the working directory correct? Are you reusing the same pointer over-and-over and letting the previous ones crash/leak memory? Travis Peterson said: and it loads then after about 100 seconds it breaks saying abort() What exactly loads? Your whole program? Where's the abort coming from? -----sig: |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You're probably leaking memory. Are you loading the same bitmap every frame without freeing it? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
GullRaDriel
Member #3,861
September 2003
|
I go with Edgar on that one, I think you are endlessly loading the bitmap. "Code is like shit - it only smells if it is not yours" |
Travis Peterson
Member #16,756
October 2017
|
Appreciate your hasty replies, at the beginning of program all the bitmaps and fonts, etc are declared in class headers and defined in their constructors, never once is an allegro bitmap freed/deleted, at end of program seemigly all objects are deleted and vectors cleared. |
GullRaDriel
Member #3,861
September 2003
|
In that case, and if your program logic isn't broken, you may have a video memory limit problem. AFAIK there had to be caveats with C++ constructor and allegro. I don't know if it's still the case with A5. Anyway, we're not getting further without a minimal portion of code reproducing your problem. I only say that because I recently broke my crystal ball. "Code is like shit - it only smells if it is not yours" |
Chris Katko
Member #1,881
January 2002
|
You can't use an Allegro function before initializing Allegro, and if you have any global classes with constructors, or classes created before init'ing Allegro, that's a crash. -----sig: |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Travis Peterson said: al_load_bitmap is called each time an object of class textdisplay is created. If you're doing this more than once, that's a memory leak. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Travis Peterson
Member #16,756
October 2017
|
al_load_bitmap called in constructor is bad? Would it be better to load them all once in a resources class and assign the bitmap of class textdisplay to the resource bitmap? |
Edgar Reynaldo
Major Reynaldo
May 2007
|
What I'm saying is, you should only load resources once. If you want to do it in a constructor fine, but be aware that global objects are created before allegro is initialized. Post more code. main, or a zip file, or whatever. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Travis Peterson
Member #16,756
October 2017
|
Your suggestion worked edgar, moved all the bitmaps initialization to a resource class and loaded them all once, then assigned the other class bitmap pointers to resources and it workes 100% appreciate the help |
|