What Should i Clean?

Blitz3D Forums/Blitz3D Programming/What Should i Clean?

KuRiX(Posted 2005) [#1]
Hello. i am running into a big problem with my game. It is almost finished, but at random times it gives me a memory access violation in random points of the code.

I think the problem is that i use ode, blitzplay, single surface libs, and of course my own entities, brushes, textures, etc...

The problem comes when i clean all and i want to start the game again.

I close ODE world, i call BP_ENdSession, i call ClearWorld, i delete all the types, i change the Resolution of the screen to force the clean of video memory...

What more should i free, clean, destroy?


LAB[au](Posted 2005) [#2]
Try putting some delay in between the different calls for closing dll's. Also try to use Freeentity, Freetexture that would be in types before deleting the type instance and before clearworld.


GfK(Posted 2005) [#3]
Nothing you're doing is freeing sounds. Probably not the problem, but still something you need to address.

I'd drop the resolution change. It looks untidy.


KuRiX(Posted 2005) [#4]
Oooooooooooh, i was freeing all perfectly. The Problem? THE FAMOUS FMOD Problem, haha.

Once the music looped one time, if freeing the music, the reloading causes a random crash some time after.

Anyway thanks all.

P.D: Just after making the topic, the first thing i tried was freeing the sounds too.

Anyway, does i need to free the sounds?

Thanks all again.


John Blackledge(Posted 2005) [#5]
If you get desparate you could always start a new copy Execfile('myprog.exe'), then End the first?


KuRiX(Posted 2005) [#6]
Hey John, that sounds interesting... Keeping a configuration data file perhaps...

Anyway, as said before, the problem was playing a .xm file.

Thanks!


Viperfish(Posted 2005) [#7]
I had major problems with .xm and .it files crashing my game. Converted them all to .ogg and haven't had a single glitch.


John Blackledge(Posted 2005) [#8]
"Hey John, that sounds interesting... Keeping a configuration data file perhaps..."

- No, you don't even have to do that.
Just know the name of your own exe (say-'myprog.exe'), make sure the current dir is your exe folder, then:
Execfile("myprog.exe") : End

Blitz will pass the Execfile command to Windows, and shut down your currently running program.

I actually need to do this when I offer users the chance to change resolutions (of course I warn them that they are about to completely restart the program; nothing so clever as Wolfenstein which does that but comes back to the original screen/position, though I guess that could be done with a little planning).


KuRiX(Posted 2005) [#9]
No, but i mean that i have stored in memory some user data, like stats... so i would need i configuration file...


jfk EO-11110(Posted 2005) [#10]
Problem with ExecFile myapp.exe is (bysides it needs to be windowed): The app will flash out and in again, you'l see the desktop for a second, and this looks pretty unpro.

I am real happy that I managed my game engine to unload everything and then restart the game. well, I don't know about some unsignificant segmentation of resources - maybe when you play a level 200 times there may be some problems, but basicly it works.


John Blackledge(Posted 2005) [#11]
Yeaj jfk, you're right of course. That is the more professional way.
But I was just trying to give him a simple solution if he doesn't want to get into a hole raft of rewriting.


KuRiX(Posted 2005) [#12]
Well, i have managed to load and unload all with two simple functions, so i can restart the game hundred of times if needed.

As jfk said, it is possible to forget something, like some small type delete, or sound unloaded, but the best idea is to have a function to load everything, then make a function that takes everything loaded unloaded.