Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / AGK2 - Memory leak using physic objects?

Author
Message
wedgeeguy
17
Years of Service
User Offline
Joined: 12th Sep 2007
Location:
Posted: 28th May 2020 19:41
Hello Everyone ...
I am creating a 3d physic pool game and have encountered what might be a problem. Since I am using physics, whenever I need to reset a visual object, I delete the physic object associated with it, reposition the visual object, then reapply the physic properties again. Whenever I do this, according to task manager, the memory keeps increasing each time (about 3-4 Mb.). I have attached a short program that follows my logic and reproduces the problem I am having. Perhaps I am doing it wrong?

Other than this issue, I am still amazed at the power and ease provided by the App Game Kit! Thank you! ... Bruce

Info:
Using AppGameKit 2 Version 2020_04_30c (Also does it with an older version 2018_08_30)
Windows 10 (32 bit)

Here is some demo code:

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 28th May 2020 22:36
Maybe you could try resetting the entire physics world
Just remember that it uses the default scale which is 30
wedgeeguy
17
Years of Service
User Offline
Joined: 12th Sep 2007
Location:
Posted: 29th May 2020 00:56
Thank you blink0k for taking a look. Implemented your suggestion using my demo provided and it did cut down the memory loss to just a little over 1 Mb. each time rather than the 3-4 Mb.. That is a lot better and I think you may be on to something. Will have to try it on the main project and see if the results are the same. I appreciate your help and I hope to post a HTML version of the larger project shortly for everyone to play ...

Thanks again!
Bruce
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 29th May 2020 01:17
Yeah. It does look like an issue. Good luck getting it fixed
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 29th May 2020 09:03
odd. i'm increasing ~1MB without Reset3DPhysicsWorld() , ~3MB with.

also noted that it isn't immediate. the balls start dropping, and the mem jumps ~a second or 2 later (before collision, which i took out as a test, etc.).
wedgeeguy
17
Years of Service
User Offline
Joined: 12th Sep 2007
Location:
Posted: 30th May 2020 15:46
Thank you blink0k and Virtual Nomad for testing. I will try to see if I can come up with a workaround and post what I came up with ... Bruce
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 30th May 2020 16:56 Edited at: 30th May 2020 16:58
still looking at this.

i'm only seeing the increase after resetting 3 or more times. ie, i don't see it on the first or 2nd reset.

and this To-Do line is concerning under void plDeleteDynamicsWorld(plDynamicsWorldHandle world) .

otherwise, i won't pretend to know the tier 2 code but whats the difference between removing and deleting the bodies? it seems that deleting does get rid of the body (btAlignedFree( body); ) while remove does not. And, while the help file suggests that both happen:
Quote: "Delete3DPhysicsBody
Description

Removes the physics body from the world and deletes it. "


i don't know if it has to do with anything. but, it might. IE, the (old) bodies are still in memory, right? and, the bodies/memory jumps are smaller if you don't set their shapes to spheres, so...
wedgeeguy
17
Years of Service
User Offline
Joined: 12th Sep 2007
Location:
Posted: 31st May 2020 19:00
Thanks again Virtual Nomad!
I believe for now I will just have to live with the memory leaks. Not looking to sell this or anything so probably will just post a notice that the program needs to be restarted after a period of time. Not the best solution but that is what I have for now. Will post a link so everyone can play coming up here. Thanks again though for your help ... Bruce
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 5th Jun 2020 07:19
wedgeeguy
17
Years of Service
User Offline
Joined: 12th Sep 2007
Location:
Posted: 6th Jun 2020 17:23
Thank you for reporting the bug!
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 9th Jun 2020 05:18 Edited at: 9th Jun 2020 06:17
this one was still bugging me so played with it some more and i believe the problem was that we weren't deleting the object, just the body. try this:

i don't know if it was, perhaps, re-creating multiple bullet shapes associated with the object(s) in the OP or what (& i don't see a GetObjectShape/BodyExists()-type command), but i see no rise in memory with the this code.

please test?

NOPE: i started mashing LMB and the memory started rising after ~10-15 clicks. less noticeable than the OP code with 1/10 the balls... back to the drawing board

AND: identical behavior without deleting anything:

so, it's the body?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 9th Jun 2020 06:16
Much less, but still leaking.
Nice work though. It's much better
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 9th Jun 2020 06:18 Edited at: 9th Jun 2020 06:27
i think its only less because it's one ball vs 10? i'm done with it for today.
and, see the last edit in my last post...

i've since deleted the kinetic body = same results.

bah!
NOW i'm DONE
wedgeeguy
17
Years of Service
User Offline
Joined: 12th Sep 2007
Location:
Posted: 9th Jun 2020 22:55
Thank you Virtual Nomad for hanging with this issue. This is where I would insert the "shrugs shoulder" emoji if there was one. I have a couple of ideas I would like to try later on. I also saw that the memory leakage was reduced if you also deleted the visual object as well as the physic object (that is kinda strange) but I too had memory increases as time went by even with that partial solution. If I stumble upon anything else then I will post what I have found here. Thanks again!
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 13th Jun 2020 19:58
btw, i've checked the official CharacterControllerRagdoll2 code hoping there was something we'd missed; it also has the memory issue when deleting bodies
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 4th Jul 2020 23:42
an update on this where the bug has been confirmed on the git by preben while blink's similar report was marked as a duplicate of it.

i smell hope
wedgeeguy
17
Years of Service
User Offline
Joined: 12th Sep 2007
Location:
Posted: 7th Jul 2020 20:20
Thank you Virtual Nomad for the update. I've got my fingers crossed ...

Login to post a reply

Server time is: 2024-11-22 05:05:32
Your offset time is: 2024-11-22 05:05:32