Logo

[SM5] Is there a way to force a garbage collection in theme?

Register Log In Back To Forums

Post #1 · Posted at 2018-10-10 01:30:43pm 2 months ago

Offline leadbman
leadbman Avatar Member
158 Posts
Australia
Reg. 2016-02-01
Log in to send this user a private message
"Working On: 5thMix BGA bgchanges"
Hi all,

My "all games in one" theme has been having some crashing errors lately with CreateTexture(1024,512,RGBA8) failed: E_OUTOFMEMORY popping up every now and then. I figure it's due to my theme requiring a lot of textures to be loaded for menu backgrounds etc.

I was wondering if it is possible to do a garbage collection of the unused textures while the theme is running? I know that SM does one when you change themes but if I could do it even when you come back to the title screen from gameplay I think this could solve my OUTOFMEMORY issue.

Hope someone can help.

Thanks in advance.
https://zenius-i-vanisher.com/ddrsig/18213.png?t=1510895050
Really need to add my scores to the tracker soon.
Always learning, always trying to push the boundaries of SM.

Post #2 · Posted at 2018-10-10 03:11:44pm 2 months ago

Offline Lirodon
Lirodon Avatar Member
740 Posts
Canada
Reg. 2009-01-14
Log in to send this user a private messageSkype: lirothedonTwitter: lirodonTumblr
Xbox Gamer Tag: LiroXIVNintendo Network ID: liroxiivSteam: listener-jubatus3DS Friend Code: 3196-5274-6831
"BBCode Not Allowed"

Last updated: 2018-10-10 03:13pm
You can make debug builds of StepMania by setting the release type to Debug when invoking CMake before compilation.

However, me and another group of developers are actually well aware of what's going on here. You have actually run into a major bug that effects nearly all versions of StepMania. It's just that, in its state on these versions, it's very rare to actually trigger it, because I don't think anyone has actually made something with enough assets to run into it. But fonts are the biggest culprit due to a design flaw our lead dev discovered.
Quote
Quickman: "It is not something like TrotMania or FoonMix." you're right those are made by competent people daniel well done

Post #3 · Posted at 2018-10-10 07:43:09pm 2 months ago

Offline Daniel_BMS
Daniel_BMS Avatar Member+
537 Posts
United States
Reg. 2007-09-01
Log in to send this user a private messageYouTube
Xbox Gamer Tag: DanielBMS
Looking forward to your all games in one theme. We have not seen that many of that type of theme.
https://i.imgur.com/8ekTOeR.png

Post #4 · Posted at 2018-10-10 11:48:24pm 2 months ago

Offline leadbman
leadbman Avatar Member
158 Posts
Australia
Reg. 2016-02-01
Log in to send this user a private message
"Working On: 5thMix BGA bgchanges"

Last updated: 2018-10-11 12:43am
Thanks for that Lirodon. I figured it might be a bug - but it actually might not be completely SM's issue - the theme is well over 2gb in size right now so it may just be going over the 4gb memory that SM allows (or at least what I can see it is allowed to use in the logs).

I'll try to further optimise my code/assets and see if that helps a bit. Font wise I'm only using a couple of "standard" fonts, for the theming that I'm doing I'm mainly using images for text that is required by other games, but in saying that I'll look into my font situation regardless.

I've noticed that the crash mainly occurs after I've come back to the title screen then move through the first menus. I think it may also have something to do with the fact that I kind of "cheat" the file system a little bit. When you move through the theme it does the following:

When you select your profile I've got the theme to ascertain what mix the player last played, it opens a screen playing/displaying the mixes background and then it writes the mixes commonbg loop music filename into a redirect file in the Sounds folder, then before the next screen loads in, I reload the theme so that the updated redir file will play the correct audio file - rather than playing the cached file from first load.

When I'm doing that, I think because I have some textures loaded e.g. the background image, movie or animation, the game tries to reload that while it's playing, maybe causing a possible crash?

I figured doing it that way rather than having multiple audio file calls might be easier on the memory usage and would allow me to have the one audio file play across several starting screens but I may have to go back to that method if that's what's causing the issue.

Looks like I'll just have to further optimise my code and assets, then if it's still crashing I'll try sorting out the reload and try to work out a way to do it without using that method.

EDIT: Interestingly I just removed the THEME:ReloadMetrics(); from the start and the audio files are still changing correctly. So maybe that'll keep it stable without that call.

------------------------------------------------------------------------------------------------------------------------------------------------

Daniel_BMS - Thanks, I can show it as it is now, but I won't ever release it though, which is why I haven't been putting it up here unless I've been asking for help as I don't want to make people annoyed if I don't release it. The theme is well over 2gb and requires specific assets such as announcer packs, characters, etc which I couldn't include as well as several rips of background movies etc that I've taken from my games so I wouldn't want to run into issues with that.

Plus, I've used some code/assets from other peoples themes for things like lifebars and judgement images etc so I wouldn't want to put my theme out publicly as that's not fair to other developers if they don't want others to use their code/images etc.

Also, there are a number of "incorrect" ways or hardcoded ways that I've done things in order to get it exactly how I want it and I don't want people to have issues that I may or may not be able to help with or get criticism for doing it that way when it's just mainly for my own use (I'm open to constructive criticism but sometimes on forums it doesn't come across that way).

It originally spawned from an idea I had back in 2004/2005 when I first started coding for SM3.9 but I couldn't achieve what I wanted, now with SM5 I finally have. I will try to put a video or screenshots up once I've sorted out this bug as it's been bothering me for a bit now and I want to deal with it before it gets worse.
https://zenius-i-vanisher.com/ddrsig/18213.png?t=1510895050
Really need to add my scores to the tracker soon.
Always learning, always trying to push the boundaries of SM.

Post #5 · Posted at 2018-10-11 02:13:47pm 2 months ago

Offline MadkaT
MadkaT Avatar Member
736 Posts
Not Set
Reg. 2009-11-24
Log in to send this user a private messageFacebookTwitter: decilantro

Last updated: 2018-10-11 02:14pm
There is no need to write files for those changes, in your case the bgsound, just use a global var, and with playsound, call the respective bgs, and for the defaults bgsound, just use a 1sec silence track with no loop (or best redir to silence in fallback if you use it), that avoids writing a file every time. Tongue

Post #6 · Posted at 2018-10-12 09:57:21am 2 months ago

Offline leadbman
leadbman Avatar Member
158 Posts
Australia
Reg. 2016-02-01
Log in to send this user a private message
"Working On: 5thMix BGA bgchanges"

Last updated: 2018-10-12 10:12am
I don't actually write new files for each song, I just edit the redirect file from the Sounds folder by opening it within my code and changing the text inside of it.

I'm still having this out of memory issue. If anyone knows what the limit of assets is, please let me know and I might be able to downsize the theme a bit to conserve memory. I'm thinking it might be the video files used for the mix backgrounds of the select music/select styles etc of the theme. I don't think that my images would be taking up too much.

Will report back if I can work this out a bit better in case others have the same issue down the line.

Actually, is it possible to unload the actors when calling the OffCommand? If so, maybe I could at least unload the videos, freeing up memory. There must be a way I'm sure. I'll try to look into it.
https://zenius-i-vanisher.com/ddrsig/18213.png?t=1510895050
Really need to add my scores to the tracker soon.
Always learning, always trying to push the boundaries of SM.

Post #7 · Posted at 2018-10-12 01:23:56pm 1.9 months ago

Offline MadkaT
MadkaT Avatar Member
736 Posts
Not Set
Reg. 2009-11-24
Log in to send this user a private messageFacebookTwitter: decilantro
I'm referring to this when I say writing files.
Quote: leadbman
I just edit the redirect file from the Sounds folder by opening it within my code and changing the text inside of it.

I think is a mixture of how you code your theme, and the quality of the videos, I only have seen this error (Not in my pc) in a theme that has HD videos in the BG, you could try reducing the quality of the videos, or loading a dummy image when you don't use it/them is hard to help without seeing what you have done.

Post #8 · Posted at 2018-10-14 03:33:14am 1.9 months ago

Offline leadbman
leadbman Avatar Member
158 Posts
Australia
Reg. 2016-02-01
Log in to send this user a private message
"Working On: 5thMix BGA bgchanges"
Ah, I thought you may have been MadkaT. I've actually found it's working well though, so I won't change it unless I really need to - it doesn't seem to be the culprit of my problem.

------------------------------------------------------------------------------------------------------------------------------------------------

I've worked out a solution that seems to be working well for me currently:

1) In all screens that load a lot of files I've changed the way I've done my if statements so that it won't load in at all unless it's specifically called for.

2) At the end of all screens that weren't automatically doing a garbage collection (that I could tell from my performance overlay that showed my RAM usage I've added at the end of one of the files per screen the following:

collectgarbage();

This global call does exactly what I needed to flush unused textures out when not being called. It's a standard Lua call and works wonders in my theme.

I've noticed there still is a memory leak going on as my RAM use increases each playthrough just a tiny amount but it still happens. So eventually I'll hit the cap and get the crash again but for the current use of my theme it seems to be fine.

If I work out any other ways to improve my optimisation I'll put them in this thread to help others if people are having a similar issue to me.
https://zenius-i-vanisher.com/ddrsig/18213.png?t=1510895050
Really need to add my scores to the tracker soon.
Always learning, always trying to push the boundaries of SM.

Post #9 · Posted at 2018-10-15 07:35:06pm 1.8 months ago

Offline Lirodon
Lirodon Avatar Member
740 Posts
Canada
Reg. 2009-01-14
Log in to send this user a private messageSkype: lirothedonTwitter: lirodonTumblr
Xbox Gamer Tag: LiroXIVNintendo Network ID: liroxiivSteam: listener-jubatus3DS Friend Code: 3196-5274-6831
"BBCode Not Allowed"
Quote: leadbman
At the end of all screens that weren't automatically doing a garbage collection (that I could tell from my performance overlay that showed my RAM usage I've added at the end of one of the files per screen the following:

collectgarbage();

This global call does exactly what I needed to flush unused textures out when not being called. It's a standard Lua call and works wonders in my theme.

do you have any code snippets showing this command being used in practice?
Quote
Quickman: "It is not something like TrotMania or FoonMix." you're right those are made by competent people daniel well done

Post #10 · Posted at 2018-10-16 11:50:28am 1.8 months ago

Offline leadbman
leadbman Avatar Member
158 Posts
Australia
Reg. 2016-02-01
Log in to send this user a private message
"Working On: 5thMix BGA bgchanges"
Sure. Just before I get to a return, for example:

local t = Def.ActorFrame {};

t[#t+1] = LoadActor("ExampleActor") .. {

InitCommand etc.

};

collectgarbage();

return t;



I'm not sure if this is the correct way to use it, however I have checked the log.txt file and it does say it's collecting garbage when the files with this call in it run. Also my RAM usage goes down when the call happens so it is working properly.

I haven't had an E_OUTOFMEMORY since I've implemented this call on all screens I was noticing my RAM wasn't lowering *knock on wood*.

So this could be something that might be helpful to be baked into the SM project or possibly could be a workaround for people running into this out of memory issue while creating a theme.

If there's any more info you need, let me know.
https://zenius-i-vanisher.com/ddrsig/18213.png?t=1510895050
Really need to add my scores to the tracker soon.
Always learning, always trying to push the boundaries of SM.

Post #11 · Posted at 2018-11-04 06:28:12pm 1.2 months ago

Offline FlameyBoy
FlameyBoy Avatar Member
335 Posts
United States
Reg. 2011-03-09
Log in to send this user a private message

Last updated: 2018-11-04 06:28pm
-
Register Log In Back To Forums

0 User(s) Viewing This Thread (Past 15 Minutes)

©2006-2018 Zenius -I- vanisher.com -5th style- IIPrivacy Policy
Web Server: 2% · Database: 4% · Server Time: 2018-12-11 11:38:21
This page took 0.01 seconds to execute.
Theme: starlight · Language: englishuk
Reset Theme & Language