Crash While Loading Images

Archives Forums/BlitzMax Bug Reports/Crash While Loading Images

KrayzBlu(Posted 2009) [#1]
Hi,

I'm in the process of loading images, and then this comes up:

main.debug(1802,0xa0652720) malloc: *** mmap(size=4198400) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug


Any help you could give would be much appreciated :)

Thanks!
~KrayzBlu


xlsior(Posted 2009) [#2]
What image format, bitdepth, and dimensions?


KrayzBlu(Posted 2009) [#3]
PNG, 32-bit, 1000x1000 pixels. It loads a few of them before the crash.


TaskMaster(Posted 2009) [#4]
Are you sure you are not running out of video memory.

Each 1000x1000 32-bit image takes up 4MB of memory.


xlsior(Posted 2009) [#5]
Are you sure you are not running out of video memory.
Each 1000x1000 32-bit image takes up 4MB of memory.


And keep in mind that the Windows desktop and such also take up a chunk in the background.


KrayzBlu(Posted 2009) [#6]
Ugh, that would suck. What determines video memory? Wouldn't the computer automatically switch to virtual memory?

Do you know how big this video memory is? (Or is it variable...?) Is it a system thing or a BlitzMax thing?

Thanks


Dreamora(Posted 2009) [#7]
graphic cards can't switch to virtual memory, driver would have but that is a DX9 only thing. Neither OpenGL (no management at all) nor DX7.
All you render onscreen must fit into the VRAM at that point or it will just crash.


xlsior(Posted 2009) [#8]
Ugh, that would suck. What determines video memory? Wouldn't the computer automatically switch to virtual memory?


No -- videocard uses very fast dedicated memory on the video adapter itself. The only exception to this are the integrated onboard videocards that don't have their own memory but use the *much slower* normal system RAM for everything -- those can expand their memory and claim more RAM. (While depending on the amount of contiguous free system RAM available to them, AND the configuration settings that may limit how much RAM is available for them)

From a technical point of view the integrated adapters are very much inferior than the dedicated cards: much slower memory interactions, underpowered GPU, and typically a few generations behind in supported features. You're going to get much better frame rates on pretty much any dedicated 3D accelerator vs. onboard graphics.

Do you know how big this video memory is? (Or is it variable...?) Is it a system thing or a BlitzMax thing?


It's a system thing. Unfortunately, Blitzmax has no built-in way to tell you how much videoram is present and/or available. It pretty much boils down to you doing the math, determinging that you use never use more than e.g. 187 MB or video RAM, add some reasonable allowance for videoRAM used by the operating system itself, and slap a '3D video card with 256MB memory'-line on the minimum system requirements of your game.

Blitz3D had a way of telling you how much available video RAM there was in DirectX. BlitzMax cannot, but technically that information should be accessible somehow. To my knowledge there is no way to query the available video memory under OpenGL.

Anyway, there are things you can do to reduce the need for video memory: for example, don't load every single background/sprite all at once at the beginning of your game, but only load them just before you need them and unload them once you are done.

If you don't have enough memory to hold everything at once (as is likely the case for you here), then you can do things like unload your menu screen once you leave the menu, unload the level 1 sprites before you load the level 2 sprites, etc. Video RAM is a finite resource...


KrayzBlu(Posted 2009) [#9]
Okay, just wasn't exactly sure what VRAM was.

Thanks!


marksibly(Posted 2009) [#10]
Hi,

malloc is not used to allocate graphics mem (and vboth dx and gl 'manage' vidmem anyway) so it's not a vidmem issue.

Can you post a runnable example - perhaps using CreateImage instead of LoadImage to make it easier to test?