Slow down after ~10 minutes

OK, so my game runs great currently 60fps 40% of cpu time is spend ending the frame/update (waiting to continue). Problem is that after ~10 minutes I get a severe slowdown ~4-10fps with occasional spikes back up to 60, the game never fully recovers. :clue:

I thought it could be related to audio as I started to really notice it around the time I added audio, and I implemented a bunch of threads with it, but all of the threads get cleaned up no problem and I’ve just recently started playing longer games consistently.

I’m not really sure what to look at next, heap size hovers just below 1000MB. The only thing I can think of is graphics hardware as I’m on a macbook pro 8GB ram 2.5ghz i5, so integrated graphics.

Not sure anybody can really answer this for me, but I’m mostly fishing for ideas.

I see that you said that the memory size hovers at about 1000mb, but I would be willing to bet that if you were using audio with relatively long clips that weren’t streamed that the usage could hover there with large slowdowns to GC and keep that ram usage stable.

I’m a little confused by what you mean. If I have a large audio file, not streamed, then the RAM will stay stable but GC will kick in?

Profile the app before and during slowdown.

@BurntPizza I have, there’s no discernible different in profile results, I’ve done it multiple times just to make sure I’m not crazy.

Edit: FYI I’m using javax.sound.sampled.Clip if that makes a difference.

Edit2: actually that’s not true, whenever I profile after swapbuffers is taking forever.

Then start removing things until the problem goes away. Start with the audio system if that’s what’s suspicious.
Tip: if you’re using git, git-bisect is good here:

I just mean that the a large audio file not streamed will use a lot of memory, and in theory with some hardcore GC the memory usage could stay stable while requiring more time each frame to GC. Although I may be really wrong, so please correct me if I am.

@BurntPizza I made an edit. Also, I know I was just seeing if anybody had an idea before I started hacking away at non-audio related stuff.

@CopyableCougar4 The file is 31MB, I’ll look into it.

Is that a compressed file? If so, the in-memory size will be much larger. Just keep that in mind.

Yeah any sound clip longer than 1 second or so should be streamed.

@BurntPizza Nope it’s a wav file, thanks for the heads up though

@CopyableCougar4 good to know.

Thanks guys!