Latest Uploads
image-25-0 ... 26-04.jpeg

Jayenkai

Help_Fight ... rivacy.png

Jayenkai

Gameboy...Colour!!

rychan

Day 1 - Ga ... eboy Racer

rychan

Pain_Claim.png

Jayenkai

Monkey Maz ... pload test

Pakz

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 | Mark Here
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 | Mark Here
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 | Mark Here
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 | Mark Here
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 | Mark Here
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 | Mark Here
Teasy


Making a little generic memory test application gives me quick results.
And I discovered that Blitz doesn't like more than ~16,384 sprites for some reason ^^

For me, on this computer, Blitz does properly allocate and deallocate memory/sprites/etc.
I have also noticed that a simple call to CreateSprite() does not increase video memory, only physical/virtual memory.

If you want to try this out for yourself, I've compiled an executable for your convenience
Memory benchmark (ZIP)

And here's the code if you're curious

-->
memory item allocation test 1b.bb

-->
MemoryInfo.BB (05 Jan 2011)

-->
String.Lib.BB (05 Jan 2011)
Homepage : http://www.bettiesart.com/tc/contact
Posted : Thursday, 06 January 2011, 05:58 | Permalink | Mark Here
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 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Latest Posts
Twitter Sillyness
Jayenkai Fri 08:04
New Spray : Enforced Fun
Jayenkai Fri 05:22
Snow!! ...?
Jayenkai Fri 03:45
Boiling Your Feet
spinal Thu 13:15
PIP Crap
Jayenkai Thu 10:47
Nintendo News - April 2016
rockford Wed 09:05
What Have You Done? - April 2016
Jayenkai Wed 04:11
AGameAWeek : 2016 - Part One
Jayenkai Wed 03:16
80s vs New York!
rockford Tue 22:22
Back to Work for Dabz
Dabz Tue 09:34
More

Latest Items
Blog : Feedback
Pakz Fri 12:15
Blog : Pixeljoint
Pakz Thu 14:08
Blog : Sprite editor getting better.
Pakz Thu 01:25
Showcase : 8-Bit Boulders
steve_ancell Wed 08:19
Blog : Testing out my Pixel editor
Pakz Wed 07:10
Dev-Diary : PS2 to N64 Adapter
Jayenkai Wed 03:07
Dev-Ideas : Pixel editor
Jayenkai Mon 23:40
Showcase : Geartography
Jayenkai Mon 02:55
Showcase : Blitzplus Pixeling Tool Project
Pakz Sun 21:36
Snippet : Sprite editor 16x16 10 colors
Jayenkai Sat 12:50
Showcase : Nags Heed Darts
Dabz Tue 11:05
News : Newsletter #259
Dabz Tue 02:20
Showcase : Farming Game
realtime Thu 18:53
News : Newsletter #258
Dabz Fri 12:59
Snippet : naturaltime.py
HoboBen Sun 01:19
More

Who's Online
HoboBen
Fri, at 12:28
Jayenkai
Fri, at 12:28
steve_ancell
Fri, at 12:27
Pakz
Fri, at 12:26
spinal
Fri, at 11:55
Dabz
Fri, at 11:50
rockford
Fri, at 11:03
shroom_monk
Fri, at 03:06
therevillsgames
Thu, at 21:57
9572AD
Thu, at 19:54
Link to this page
Site : Jayenkai 2006-Infinity | MudChat's origins, BBCode's former life, Image Scaler.