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 / Memory leak?

Author
Message
MMT
6
Years of Service
User Offline
Joined: 12th Mar 2018
Location:
Posted: 12th Mar 2018 17:57 Edited at: 12th Mar 2018 19:43
So... hello! I am new to AGK. I've bought it yesterday, since I wanted to create some simple apps.

Since I come from mostly OOP programming, going back to BASIC is fun but somewhat rocky.

enterTeamSelect() pretty much only loads the files and exitTeamSelect() deletes them.

_teamSelect is accessed by the main loop

I've tried a lot with DeleteSumthing but the problem remains, working memory use is rising and rising, thus everything becomes sluggish pretty quick.

Am I too spoiled by the garbage collector?

So, can someone point out the problem to me?

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Mar 2018 21:01
Welcome

loops like this:



is generating text entities that are not trackable and able to be deleted.
You are generating text and saving its ID in text1.
Then you immediately overwrite text1 with the ID of the next text entity. The original one still exists but you no longer have a record of its ID.

In managed OOP, the original text would be garbage-collected, but this is not the case in a basic language like AGK. Text1 is just an ID, not a reference to an object.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
MMT
6
Years of Service
User Offline
Joined: 12th Mar 2018
Location:
Posted: 12th Mar 2018 21:05
Great answer!

Like I said, I have a lot to re-think!

But it's fun!
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 12th Mar 2018 21:27 Edited at: 12th Mar 2018 21:27
Doesn't the api functions to DeleteAll (DeleteAllText in this case) delete them all? From what I understood all objects, sprites, text etc are managed by the api meaning these objects all know their ids internally which is why the api commands reference an instance by its id. And DeleteAllText would then automatically delete them all and reset the internel auto id counter to 0 as well?
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 13th Mar 2018 09:27
You still need to manually call DeleteAllText , which isn't clear in the above sample.
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 13th Mar 2018 13:28
Yes definitely. I was just thinking about them not being tracked. The code is not explicitly tracking storing all of the ids but internally they are stored and calling DeleteAllText should delete all of them.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)

Login to post a reply

Server time is: 2024-11-27 14:39:36
Your offset time is: 2024-11-27 14:39:36