0

I want to debug which part that consume most of mono memory in Unity because what I saw from profiler is only a chunk said "Mono" something like that and do not know what it is.

I have already done the texture observe in Unity profiler and I do not have a problem with it. (I stated that I used it and saw only mono chunk with high memory) The problem is there must be some kind of memory leak not memory spike because if I play the game long enough, my Galaxy Grand Duo will crash with black texture which is memory used too much. If I saw it in the profiler, it said ManagedHeap and Mono Domain only with large chunk of memory after play the game multiple times.

Paiboon Panusbordee
  • 781
  • 2
  • 10
  • 26

1 Answers1

1

More information about which platform you are developing for, which tools you are already using, and the reason you are profiling your memory to begin with would be helpful. Without that information I can only suggest the following ...

1) Unity Memory Profiler

I would recommend starting with the memory profiling tools included with the Unity3D editor. You can find out more about these tools here: http://docs.unity3d.com/Manual/ProfilerMemory.html

It sounds like you are already doing this since you have narrowed it down the the "Mono" item from the profiler. This is good, you now know that it is one of your scripts that is consuming the memory.

Make sure you are using the Advanced View. The advanced view of the Unity Profiler will give you more information about which scripts are utilizing your memory.

2) Textures

When it comes to Unity and memory I always start with the textures. It seems like every time I do something with dynamic loading or modifying of textures I end up creating a memory leak. Take a look at your scripts, particularly any that load textures, and try temporarily disabling this logic. Does it help your memory issue?

3) Observe and Optimize

If you aren't able to locate any scripts that seem like they could be causing an issue, I would try observing your game and locating the point where you see your memory spike. Try to identify what logic is running at this point in time. Disable individual scripts and run your scene again. Did this reduce the memory usage? Repeat this process until you locate the script or scripts responsible for your spike. Once you find these scripts you can try re-factoring them until you get the results you are looking for.

Shawn Lehner
  • 1,293
  • 7
  • 14
  • I have already done the texture observe in Unity profiler and I do not have a problem with it. (I stated that I used it and saw only mono chunk with high memory) The problem is there must be some kind of memory leak not memory spike because if I play the game long enough, my Galaxy Grand Duo will crash with black texture which is memory used too much. If I saw it in the profiler, it said ManagedHeap and Mono Domain only with large chunk of memory after play the game multiple times. – Paiboon Panusbordee Jul 24 '15 at 06:59
  • Have you switched your profiler to advanced mode? Check out this screenshot: http://docs.unity3d.com/uploads/Main/ProfilerMemoryDetailed.png – Shawn Lehner Jul 24 '15 at 18:27
  • Yes, I already done that and I saw mono memory used from the part. Example of memory used too much is string concatenation in the loop. That will trigger the dynamic memory usage to create a new chunk every time. What I want is to specify which code has that kind of stuff to leak memory or maybe some other case that leak memory too. – Paiboon Panusbordee Jul 25 '15 at 04:55
  • I would think that information should be enough for you to track down the code by reviewing the functionality of your scripts. The only other course of action I could think of would be to create a Windows build of your application and try to attach one of the many .NET memory profilers such as: http://www.red-gate.com/products/dotnet-development/ants-memory-profiler/ – Shawn Lehner Jul 25 '15 at 12:51