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 / AGK's garbage collection

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Mar 2017 17:25
This is referring to Tier 1 in AppGameKit 2.

I have a function which defines an array inside of it. The array itself holds the DOM information from my XML library. Once I'm done extracting what I need, the function ends. Now once that function ends, I assume any variables created inside are automatically cleaned up. But this is where I found something odd. I ran my program multiple times and checked it's memory usage in task manager, each time coming out to about 53,800 KB (give or take a few bytes). But when I try to clear the array from memory myself by emptying it ( array.length = -1 ) at the end of the function, the memory usage is higher. About 300KB higher. I don't know the size of the array so I can't even guess what those extra 300KB pertain to. After testing this several times, the results are pretty consistent. My app uses more memory when clearing the array than if I had just left it alone.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 9th Mar 2017 18:29
Interesting thesis.
I cannot reproduce that...my test app is growing a little bit for a few seconds and if I use array.length = -1 It shrinks again
Did you tried it with .remove() or with dim also ?

Using AGKv2 Tier1
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Mar 2017 19:19
I ran it 4 times per case, giving it a minute to stablize each time.

With array.length = -1


without


It's not as big of a difference now but on average there is still a difference. What's stranger is that now it shows in favor of clearing the array. I tried using remove() and the results varied, fitting in with the numbers from either test case above., but on average being closer to that of using length = -1

It's odd. Maybe it's nothing. I'm not sure. I just don't like inconsistencies.


"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
MadBit
VIP Member
Gold Codemaster
15
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 10th Mar 2017 08:02
I have played a bit with arrays.

This is the code.


And my results.


This is a difference of 16,596 bytes between filling the array and deleting the array.

I don't know what is not released there. I have run the test without the string. There was a difference of 4,396 bytes.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Mar 2017 08:24
There is probably a difference between clearing your program data, and the system garbage collection. GC will recover memory in blocks (e.g 64K). It will also depend what other data is stored alongside and whether that can be recovered. It's also worth noting that GC does not necessarily recover unused memory. It only recovers memory if it is required by something else.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Mar 2017 16:14
Quote: "It only recovers memory if it is required by something else."

Kind of like a quick format? Doesn't actually erase sectors, just marks them as available when needed?

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2024-11-24 19:33:12
Your offset time is: 2024-11-24 19:33:12