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.

Newcomers AppGameKit Corner / Checking for Memory Leaks

Author
Message
DavidAGK
AGK Developer
6
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 18th Jun 2018 14:10
Hi All,

Should the memory used by my game, as shown in Task Manager, be identical when I return to a certain part of my game because I've cleaned up properly (say I return to my main menu each time to check what the memory-used now says) or should I expect some variation/fluctuation (eg because of things going on in the background of my AppGameKit application that I don't know about or any other unkown-unkowns )

I think I have a leak because it's gradually increasing but wondering if I should be working to achieve an identical memory usage at a certain point in the game or whether that will never happen.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
IronManhood
5
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 19th Jun 2018 08:33
Let your app run for a few hours and see if you can fill your ram up. Seems like the most straight forward way of testing it.
puzzler2018
User Banned
Posted: 19th Jun 2018 12:58 Edited at: 19th Jun 2018 13:00
Make sure where ever you have a "Create............." something - make sure you have the subsequent "Delete..............." command to remove from memory or each level (if dont need those objects / sprites anymore after each level say

For example

Good


Bad


will have two objects thats still in memory for example
and try not to "Create" anything anywhere inside the main loop if can help it
Phaelax
DBPro Master
17
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 20th Jun 2018 13:27
I'd say you have a point where something is being created repeatedly but never deleted. Figuring out at what point in your game you start to see the increase can will find what part of the code is causing it.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
BatVink
Moderator
17
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Jun 2018 09:26
Make "Create..." functions for sprites, images, sounds etc that take the same parameters as the standard command.
In your function, add a counter to monitor what you have loaded.

Do a mass replace of all Creates to your functions.
Print() your counters to the screen.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
DavidAGK
AGK Developer
6
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 25th Jun 2018 17:33
Cheers guys - sorry for slow reply. I've been fairly careful to create "Unload" functions for all my load functions but saw I had missed a few generated sprites. I'll hammer test this at some stage to see if the memory just keeps going up or whether it bobs around.

Like the idea of having the Create functions that do the same as the original but count - that's a neat idea. I've been using the Managed Sprite and Image Memory commands to look at that and I'm definitely steady on the number being managed in both cases. My feeling is that if anything, a sound might not be being unloaded. Shame there aren't equivalent commands to see how many sounds you've got in memory (he says thinking he'd better take another look...)
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Carharttguy
4
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 26th Jun 2018 08:07
To answer your initial question: It should roughly be the same. There will be a difference between the first time you go to your main screen and the second time.
But the 10th time and 11th time should be the same. (give or take a few kb)

Gradual increase isn't good, but should be viewed in perspective. 1MB increase an hour isn't something to worry about for in a game.

Also: Leaks could be out of your reach, as the AppGameKit interpreter could also leak.
Phaelax
DBPro Master
17
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Jun 2018 13:04
Quote: "Also: Leaks could be out of your reach, as the AppGameKit interpreter could also leak."


Blasphemy! You dare speak ill of our father the Bamber?
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
puzzler2018
User Banned
Posted: 28th Jun 2018 21:16
AGK is a leak within itself - I dont think so. Paul is an awesome mathematician and an absolute genius - if there is any leaks then check our water works

DavidAGK
AGK Developer
6
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 4th Jul 2018 19:49
OK, this is weird! Started hunting it down and long story short...

If I create a brand new programme - ie I have the default blank programme that shows the fps on the screen and I compile it and then run it stand alone... it gradually increases its memory footprint! It starts and I see a fairly rapid rise, then it slows and then over time (30 mins+) I see a distinct increase in memory used by the application. My feelin is that if I left it overnight it would just use more and more memory. Latest build (2018.6.22) and under Windows 10.

Makes me trying to find memory leaks in my application rather hard!

Any clues? Do you guys get this?
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
DavidAGK
AGK Developer
6
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 4th Jul 2018 19:50
This is the default programme I'm referring to...

Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
DavidAGK
AGK Developer
6
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 5th Jul 2018 17:12
Think I'll start this as another thread in the main chat section because something definitely feels wrong abut this....
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Golelorn
3
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 6th Jul 2018 06:22 Edited at: 6th Jul 2018 06:30
I have left my programs running overnight many times on an accident, and I have never experienced this. I have included screenshots. Its not optimized, and I stay at a steady 71 MB.


Right after load:


After 5 minutes:


The funny thing is the game( 32 bit ) in the background is a 2d game called Dragon Cliff. I am shocked its using that much CPU power! Thank goodness, I decided to stop letting it run all night. I started to worry it might burn up my CPU. Looks like I was right! WOW.

Attachments

Login to view attachments
TomToad
2
Years of Service
User Offline
Joined: 6th Jan 2018
Location:
Posted: 6th Jul 2018 10:51
I think it is just the garbage collector. The GC determines the most efficient time to remove objects from memory based on performance and resources. Memory won't necessarily be freed the moment you delete the object, so seeing memory usage increase a few MB for the first 10-20 minutes isn't unusual. See my response to this thread. https://forum.thegamecreators.com/thread/222565#msg2626976
Phaelax
DBPro Master
17
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Jul 2018 13:49
I wouldn't be surprised if this issue is isolated to only Win10 machines. I've had multiple programs (not-agk stuff) that run fine under Win7 but in 10 it eats up resources like crazy. Chrome is one of them. I could have a browser open for a few days and it'll use 14GB of memory! Close it and reopen with the exact same tabs and it might only be 1GB. Never had that happen on Win7.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
c0d3r9
AGK Developer
3
Years of Service
User Offline
Joined: 2nd Oct 2017
Location:
Posted: 6th Jul 2018 14:38
But that memory eating behavior is know with browsers.
I have only 8GB on laptop/desktop :-(

Login to post a reply

Server time is: 2020-10-22 02:21:32
Your offset time is: 2020-10-22 02:21:32