- Home /
Huge memory consumption even on windows
I have made a game when running on (PC) it is consuming about 219,500K memory when I see in windows task manager. Game is hanging and lagging a bit as well. Seems memory consumption problem. exe is just about 17 mb. I am worried as it is my first scene and haven't ported yet it on small devices i.e. iphone/Android
Answer by tanoshimi · May 17, 2015 at 07:21 AM
Memory usage is completely unrelated to .exe size - you can cause a memory overflow with a single-line infinite loop.... You need to use the profiler to see what's going on.
I just used profiler.GetRuntime$$anonymous$$emorySize to get the size of textures in use. I noticed it is 53 $$anonymous$$B :(. But still I have 150 $$anonymous$$B of unknown things. $$anonymous$$y character size is about 280 bytes. I am generating a prefab continously after every 30 seconds also about 280 Bytes(too small). Am I missing anything ?
@fahimalavi: Yes you probably miss something ^^
btw the size of the exe file is constant. When you create a build absolutely nothing is changed on the exe. The exe is just the UnityEngine. It's a playback engine for your game. Your actual game data is in the _Data folder next to the exe file ^^.
Also keep in $$anonymous$$d that Unity uses a managed environment. Usually once the $$anonymous$$ono engine has requested system memory it does not necessarily free the system memory if it's no longer in use. From the managed point of view the memory is "free" so the managed memory manager can use this memory if needed. The memory usage you see in the Task$$anonymous$$anager doesn't say anything about the actual usage.
Try System.GC.GetTotal$$anonymous$$emory(false). If you use System.GC.GetTotal$$anonymous$$emory(true) the garbage collector collects all garbage before calculating the used memory. Since there's always some garbage waiting to be collected with "true" the size will be smaller. However if you average the values returned by System.GC.GetTotal$$anonymous$$emory(false) over a period of time you get a more realistic value.
@Bunny83 and @tanoshimi Thanks all, it found out to be 63 mb :) but game is still lagging. I need to look into CPU usage as well, optimizations and Profiling
Your answer
Follow this Question
Related Questions
Unity iOS memory usage 0 Answers
Lost texture in Android build 0 Answers
Assigning UV Map to model at runtime 0 Answers
Duplicate Texture Memory with Sprite Atlas 0 Answers
Compressed texture using same memory as uncompressed in run time? Please clear up. 2 Answers