Quantcast
Channel: Latest Questions by x4000
Viewing all articles
Browse latest Browse all 49

How to stop sound from skipping during GC collection?

$
0
0

I've seen this question, of course. Granted, you want the GC to run as infrequently as possible. But, I have a very large game, and in mine it often runs about every 8 seconds.

This is most troubling for the music, though it's annoying in general. It essentially causes the music to skip every 8 seconds or so. I've tried setting the priority of the audiosource to 0, but that doesn't seem to affect the priority of the music itself. I should mention that I'm streaming this off the disk from a WWW class.

In the past, using DirectSound through SlimDX, the music ran in a separate thread that I could set the priority on. No matter what happened with playback in my game, GC collections or otherwise, the music would keep going. Is there some way to make this happen in Unity?

Why The GC Runs That Often

To go ahead and answer the inevitable question: no, I'm not crazy, and yes, this should work -- AI War has been out since May 2009 on a different platform, and I'm just now porting it to Unity.

I'm keeping track of 10,000 to 175,000 player units, and hundreds of thousands of small objects (floating junk, weapon shots, etc), and beyond that am processing a very large amount of targeting data. Not to mention several thousand commands per second, often. And a really intensive AI thread, with data being passed back and forth from the main thread to it.

All this is to say, the GC runs a lot, and to stave off the suggestions of "make it run less frequently," I can say that I'm amazed it runs as infrequently as it does (overall -- granted, it seems to like to keep a smaller memory footprint at the start than I'd prefer, collecting every time the cap hits 400ish MB when there are hundreds more available).

With a better GC -- like the one I used to have in .NET or, apparently, the experimental one in Mono 2.8 -- this wouldn't even be an issue. But the GC in Mono 2.6 is substantially more limited and lower-performance, so my main goal right now is to avoid the music skipping at the very least.


Viewing all articles
Browse latest Browse all 49

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>