Hi there, I've been doing some profiling recently and in the profiler I see that SendMouseEvents.DoSendMouseEvents() is always present and allocates 76 bytes (if the mouse is not over the game window) or around 1.8K when it is. Is this a real method or is it something to do with profiling the app? I am profiling in the editor ATM.
I ask because I have been following the advice of doing a GC.Collect() every 30 frames, but contrary to the advice this is profiling as taking around 12MS (and not 5MS) and that's on the desktop, the amount of memory allocated in this time is small < 60K. Is this collection inflated in the profiler?
I am also very interested in this...
Incidentally the GC.Collect() can only occur every frame if your heap size is small, mine was more like 3MB and this takes a long time to collect, especially on mobile. We've taken Unity's advice and:
GC.Collect() when we can - opening player's inventory; loading a level
Artificially allocate on the heap to cause the heap to grow and then free that up. This gives us 3MB of headroom, so a a collect only happens by itself every 10-20 minutes. The player will find some item and enter the inventory in this time typically I would imagine.
We're still trying to find out what is allocating, but I've not profiled for memory leaks lately...
Any news on this? I'm also seeing this in my project. It's the only thing allocating any memory while the game is running, so I'd really like to get rid of it.
I chatted to someone at Unite about this - practical upshot is that it's some internal Unity thing.
Also should point out that in Unity 3 there are significant differences and inaccuracies between deep profile and ordinary profile mode when viewing memory allocations.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
7 People are following this question.
Total memory allocated increases indefinately from .80GB untill crash
How to manage memory in a 2D Platformer game?
How do I get my game to run faster?