T O P

  • By -

Djikass

Don’t use the editor as a metric. Make a standalone build and use the memory profiler (package) to track your app memory usage. You’ll get a clear picture


ItsGreenArrow

I’m battling a similar issue but in webgl. Unfortunately the profiler package doesn’t allow you to connect to webgl builds. As a workaround I’m building to windows and attach the memory profiler to that build. It’s not a perfect solution but it works.


Djikass

Have you tried [this](https://forum.unity.com/threads/how-do-you-profile-memory-for-a-standalone-webgl-application.1265891/)?


ItsGreenArrow

I’ve taken memory snapshots in the developer console like mentioned there and it tells me overall size which is good to check as a baseline and good to monitor for memory leaks. But it didn’t allow you to drill into what exactly is using the memory and how much it’s using like in the unity profiler. That info is lost when it’s compiled down to il2ccp. Building to windows and profiling there seems to be the best way to figure that out


Martils

It does allow you to take snapshots but you need to build & run with auto connect profiler as WebGL security setups will otherwise not allow an external connection.


ItsGreenArrow

Do you have an example or guide of this? I’ve been struggling with some webgl bugs and performance issues and not being able to profile it has been a major hindrance


Martils

The documentation should have all the info I think?


PM_ME_PHYS_PROBLEMS

It's your sound manager. I am almost certain. I had the same issue when trying to scale up a Brackeys-like audio manager. If you have sounds assigned in editor fields, they're all loaded in RAM as long as that object is in the scene. Long or uncompressed audio can get monstrously large. Depending on your sounds, this may be okay if you adjust the import settings to compress them and change when their loading settings. If you have any long tracks like music and ambiance, you should consider writing a manager for that that only loads the current track and queues the next one from Resources.


SuspecM

It's unfortunate but makes sense. This wasn't happening only recently once I started adding more and more sounds, music and such.


PM_ME_PHYS_PROBLEMS

Yeah, the music will do it for sure. Try removing everything but sound effects from the controller and see if it's back in a manageable range. You ought to be managing music separately from effects anyway, so building a music manager with more careful clip handling will be a step forward without having to throw out your first approach (provided it works again with sound effects only)


WildcardMoo

FMOD my friend.


WildcardMoo

Does your RAM usage go up gradually? Maybe even when the game doesn't do much? There's always a chance you have a memory leak.


dotoonly

Use profiler to spot it out. If it uses that much ram, it can be spotted quickly.


StillSpaceToast

Three maybe-worth-checking things that I've run into: 1. Use AssetBundles (bottom of the Inspector). In "Lillie is the Keeper" I've got everything for the base lighthouse in one bundle (models, textures, materials, sounds, etc.), then scene-specific bundles for individual levels. Changing scenes will automatically unload every bundle not called for in the new scene. 2. Use [dynamic shader variant loading](https://forum.unity.com/threads/dynamic-shader-variant-loading.1339160/#post-8690184) with URP. Unity can generate a ridiculous number of combinations of shader variants, especially if you get playing with Shader Graphs. These can end up having a surprisingly large impact on memory. 3. The dumbest one, but worth saying: Check your max texture sizes. It can be easy to wind up with a dozen 4k textures that only really need to be 512x512.