loadImage / FreeImage

Blitz3D Forums/Blitz3D Beginners Area/loadImage / FreeImage

Dirk Knoop(Posted 2006) [#1]
If I run the following code, the programm will chrashes after some minutes.
This code is only an example to demostrate the problem in my new game.
In my new game I need very many graphics. I have to reload some graphics, because they are to many.

What can I do ?

Kind Regards,

Dirk Knoop

Graphics 1024,768,32,1
SetBuffer BackBuffer()

Repeat

If KeyHit(1)=1 Then End

c=c+1
Cls
Text 10,10,c
Flip

picture=LoadImage("picture.png")
FreeImage picture

Forever


Nicstt(Posted 2006) [#2]
don't free the image till the gfx is finished with, i moved the freeimage instruction to outside the loop, same with loadimage

picture=LoadImage("picture.png")

Repeat

c=c+1
Cls
; display stuff here - such as loaded gfx

Text 10,10,c
Flip
Until KeyHit(1) ; simpler to have the exit check here - personal preference though

FreeImage picture

;perhaps also have a check to make sure image exists before freeing it

if picture <> 0 then freeimage picture


Matty(Posted 2006) [#3]
Which version of blitz do you have? The upgrade to version 1.92/3/4/5? had problems with freeing resources (1.90/1.91 didn't and supposedly everything works with 1.96 which we are at now).


Dirk Knoop(Posted 2006) [#4]
Thank you for answering.
I used V 1.94, now I updated to V1.96.

I will try the code now for 15 hours.

Thank you Matty!

Dirk Knoop


Sir Gak(Posted 2006) [#5]
Dirk, aren you saying that you are going to load a picture file from your harddrive for 15 hours straight? Isn't that putting a wee bit excessive wear-and-tear on your hard drive? Granted, modern hard drives are usually rated for 100,000 hours (which is a lot more than 15). Still, it seems extravagant.


H&K(Posted 2006) [#6]
Maybe he has a vertual Ram draive


Dirk Knoop(Posted 2006) [#7]
100000 hours are 4166 days. That means 11 years.
I donīt want to use my computer for 11 years :-)

It was just an extremly test.


n8r2k(Posted 2006) [#8]
do you mean extremity test? because thats definitly what your code will do - 15 hours *shakes his head in disbelievement*


Sir Gak(Posted 2006) [#9]
Dirk, that's 11.4 years, if you use floating point ;o)

You know, in 100,000 hours, I think it will be a good bet that you will be using a new computer anyway on a whole new technological level that surpasses anything in the world today. Today's best 3D graphics cards will be crude, bargain-basement, close-out junk compared to the tech of tomorrow (especially 11.4 years of tomorrows).

BTW, if you don't mind my asking, how many graphics ARE you using? In your original post, you said
In my new game I need very many graphics. I have to reload some graphics, because they are to many.

How many is too many?


Ross C(Posted 2006) [#10]
It's a bit strange to be thrashing the harddisc like that. Come to think of it, won't the hard discs cache, store this, if it's so frequently used?