Latest Uploads
Title Anim ... d Biomorph

Andy_A

Investigating

Jayenkai

Fancy Robot

Jayenkai

Top Secret

Jayenkai

Bargain

Jayenkai

Time for a ... op perhaps

Jayenkai

Forum Home

Freeing memory in B3D

UserMessage
Posted : Monday, 03 January 2011, 13:38 | Permalink
Tikihead


WW Entries : 7
Hello everyone, is it possible to declare a variable as an entity in Blitz3D? I ask this because I'm working on a 2D in 3D game and it has something similar to the following code...
-->
...and freeing "f\sprite" doesn't free up the ram it used in the first place. I do that (create an entity, free it) countless times in my game so it's something I have to fix. I suspect that I'm having a problem because "FreeEntity()" is looking for an entity but "f\sprite" was declared as an integer as Blitz does when you don't declare what datatype something is. Any tips? Thanks.
Posted : Monday, 03 January 2011, 14:00 | Permalink
JL235


WW Entries : 7
The handles for entities are essentially just ints. So your code should be correct.

How do you know the ram isn't being freed. Are you running out of memory?

Also I doubt the entity is using up ram (or at least very little). It'll be using video memory instead.

-----
PlayMyCode.com - build and play in your browser, Blog, Twitter.
Homepage : http://www.StudioFortress.com
Posted : Monday, 03 January 2011, 16:20 | Permalink
Tikihead


WW Entries : 7
The entities in question belong to bullet objects, so there's a lot of them being created and shortly thereafter freed. I'll boot up my game, it'll be using around 17k of memory, I'll fire bullets for a while, and the memory usage will go up a few thousand and won't come back down. If I start firing again, it goes up more, etc.

The video memory is freed up when I delete and free the bullet and entity instances. However, the memory usage (as seen in task manager) keeps on increasing and never goes back down.
Posted : Monday, 03 January 2011, 16:28 | Permalink
HoboBen


WW Entries : 9
Possibly fragmentation of memory - things being created, then freed all over the place might lead to blocks of memory too small to fit new objects in again, so the memory used has to grow.

Particle engines usually create a fixed size amount of particles at once and simply hide/show them. This means that there's no costly memory allocation and also no fragmentation. You could use a similar technique for your bullets.



-----
Posted : Monday, 03 January 2011, 16:32 | Permalink
JL235


WW Entries : 7
If he is freeing them then fragmentation wouldn't be an issue. It would only affect performance.

-----
PlayMyCode.com - build and play in your browser, Blog, Twitter.
Homepage : http://www.StudioFortress.com
Posted : Tuesday, 04 January 2011, 15:14 | Permalink
Tikihead


WW Entries : 7
Well I'll try what Ben suggested within the next few days and see how that goes.
Posted : Wednesday, 05 January 2011, 03:24 | Permalink
Teasy


Homepage : http://www.bettiesart.com/tc/contact
Posted : Thursday, 06 January 2011, 05:58 | Permalink
Tikihead


WW Entries : 7
Wow, thanks Teasy. I tried your code and it freed the memory it allocated appropriately. Since that's the case, I'll have to debug my code more to figure out where all the memory usage is. Arg.
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 142|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Latest Posts
Decorations
therevillsgames Mon 16:07
Advent Calendars - 2016
Jayenkai Mon 14:20
Monkey Fullscreen
Jayenkai Mon 14:00
AGameAWeek : 2017 - Part One
Jayenkai Mon 13:56
UT or QIIIA
rychan Mon 13:41
The Grand Tour (ex-Top Gear)
Jayenkai Sun 14:53
M+M decisions
rockford Sun 05:21
Android Consoles aren't surviving
9572AD Sat 21:37
Gatlinburg Fire
Stealth Sat 19:48
Pop Quiz, HotShot
Jayenkai Fri 13:22
More

Latest Items
Woot : My Music
Jayenkai Sat 14:20
Snippet : Grass like image generator
Pakz Thu 00:09
Pets : Molly On The Couch
Jayenkai Wed 05:32
Snippet : Grid Menu
Pakz Mon 12:15
Showcase : Gamma Collexion
Jayenkai Sun 12:56
Showcase : SSASE
spinal Sun 07:51
Snippet : Water in 2d map
Stealth Sat 20:19
News : Newsletter #292
rockford Fri 12:16
Showcase : Mining Map AI Demo
Stealth Wed 08:02
Blog : Spilling my Noodles
Jayenkai Tue 21:58
Dev-Diary : Current Direction
Pakz Tue 13:46
Showcase : Biomorph Fractals
Andy_A Tue 13:15
News : Newsletter #291
steve_ancell Fri 08:56
Snippet : Futuristic Weapon Images
Pakz Fri 04:01
Snippet : Face Formula
Andy_A Thu 14:56
More

Who's Online
steve_ancell
Mon, at 18:57
shroom_monk
Mon, at 17:26
Jayenkai
Mon, at 16:11
therevillsgames
Mon, at 16:07
LineOf7s
Mon, at 15:39
GfK
Mon, at 15:34
Pakz
Mon, at 15:26
rockford
Mon, at 15:22
zzoom
Mon, at 15:15
rychan
Mon, at 14:50
Link to this page
Site : Jayenkai 2006-Infinity | MudChat's origins, BBCode's former life, Image Scaler.