deleting stuff

Blitz3D Forums/Blitz3D Beginners Area/deleting stuff

Nate the Great(Posted 2008) [#1]
I was just wandering if it is bad for your computer or if it will slow it down if you don't delete things you make like types and variables?


GfK(Posted 2008) [#2]
I was just wandering if it is bad for your computer or if it will slow it down if you don't delete things you make like types and variables?
First, 'wondering' and 'wandering' are two entirely different things. You want the former.

Not deleting things is commonly called a memory leak, and yes, its bad. You need to clean up after yourself.


Nate the Great(Posted 2008) [#3]
I always assumed blitz deleted them for you. What exactly does it do to your computer and how can I "clean up after myself" if I have already run the program that didn't delete anything that it created?


Nate the Great(Posted 2008) [#4]
That could explain why my old computer crashed.


mtnhome3d(Posted 2008) [#5]
EndGraphics
will clear every graphical and otherwise objects in the program except vars.


Nate the Great(Posted 2008) [#6]
I didn't know about the endgraphics command. Thnx. What can happen to your computer if you never delete anything?


Gabriel(Posted 2008) [#7]
What can happen to your computer if you never delete anything?

Absolutely nothing. Blitz3D tries to automatically return all memory when the program ends. If by some chance, the memory was not freed, then some memory would remain used and not useable by the system until you restarted or switched off your computer.

It is highly unlikely that you would ever cause any damage to your computer hardware by programming. You can delete files and/or corrupt the registry if you use file or registry commands, but otherwise, no chance. Modern languages, and particularly very high level languages such as Blitz3D, simply don't let you program the hardware so there is nothing you can damage.


Mortiis(Posted 2008) [#8]
You will run out of ram, and windows will pop up a message about it "Not enough memory etc." in the system tray. Then you restart the computer if it doesn't crash or freeze (because it will get extremely slow). After the restart everything will turn fine again.

But to make this happen you need to use extreme amounts of ram with your application.


Nate the Great(Posted 2008) [#9]
Ok. I better restart my computer pretty soon because I have been running a lot of old programs I made that don't delete anything.

"Not enough memory"
That message sounds familliar. hmm mabey that's the message I got before my old computer crashed


Doiron(Posted 2008) [#10]
will clear every graphical and otherwise objects in the program except vars.

You can also manage and free your media without terminating the graphics.

It is good practice to free your memory as soon as you don't need an entity, a sound or an image anymore, expecially if you are loading heavy files which would eventually fill up the available RAM and VRAM.

Take a look at all the commands with the "free" prefix, such as (but not limited to) 'FreeFont', 'FreeSound', 'FreeEntity', 'FreeImage', 'FreeTexture'.

Also, be sure to clear unused types which you don't need anymore by using the 'delete' command only *after* freeing all the fields in it, or the content will stay in memory but you won't be able to access it anymore.

In order to elude stuttering and pauses avoid to manage your media during gameplay, too.


Doiron(Posted 2008) [#11]
Ok. I better restart my computer pretty soon because I have been running a lot of old programs I made that don't delete anything.

You don't need to restart the computer: As soon as you exit the program, all the used memory is freed.


Mortiis(Posted 2008) [#12]
You don't need to restart the computer: As soon as you exit the program, all the used memory is freed.


If you don't use ClearWorld or EndGraphics your program will cause a memory leak so that means;

1.You have to restart your computer or
2.You need a memory cleaner application


GfK(Posted 2008) [#13]
will clear every graphical and otherwise objects in the program except vars.
This is completely wrong.

EndGraphics does not delete any custom Types. Nor does it delete any sounds.

The same goes for ClearWorld - read the documentation. It tells you exactly what it gets rid of. Assume that everything that isn't mentioned remains.

Its extremely bad practice to not clear everything manually. Especially as there isn't any other reliable method of doing it.


chwaga(Posted 2008) [#14]
blitz3d automatically cleans up after itself after shutting down. However, it is VERY often more effective to clean up yourself as needed DURING the application, both as a good programming practice, and to speed things up.


Nate the Great(Posted 2008) [#15]
Ok thanks. I just assumed it deleted everything you used automaticly, however I have recently started deleting everying. How do you delete variables? var = Null ?


mtnhome3d(Posted 2008) [#16]
null is for types only


Nate the Great(Posted 2008) [#17]
How do you delete variables?


Gabriel(Posted 2008) [#18]
You don't. They're deleted automatically at the end of the program.


Ross C(Posted 2008) [#19]
I'm sure the way it works is Blitz3d is allocated memory. When you create new vars etc etc, blitz3d asks for more memory to be allocated. When the program ends, windows unloads the app and frees the whole chunk of memory so it may be used again.

I'm not sure if VRAM works the same way though... But as said above, you shouldn't have any problem. Think about it. Your running your game, you have sounds and graphics and types all created, then suddenly, the game crashes and you end task on it. I've never seen a memory leak occur because of that.

Windows memory management is very good.


Nate the Great(Posted 2008) [#20]
Ok thanks everyone. I was just worried that I may be ruining my computer when I found a blog post from a few years ago that made it sound like your computer would crash if you didn't delete anything.


Ross C(Posted 2008) [#21]
It would eventually, if you left the program running and didn't delete types and sounds etc, and kept creating new ones.


Doiron(Posted 2008) [#22]
Usually terminating the process from the Task Manager does the trick.
It's very difficult to have an irreversible crash due to B3D programming.


Kryzon(Posted 2008) [#23]
I never free anything (unless in-between levels and you don't need that stuff anymore, of course). Windows [and perhaps blitz, I don't know] take care to free the memory the application used in the end.

When it's small enough, I don't use memory commands. When it's big enough to cause some damage, I only free whatever I won't use again.