Memory Leak Help

I wasn’t keeping an eye on the profiler and the taskmanager for my Game’s memory. Now, when I decided to check, I certainly do have a memory leak. The profiler shows(also the task manager) my memory is increasing by 1MB everytime I run the game. So, I tried everything, including my code check, couldn’t figure it out. finally decided to make a backup of the whole game folder then tried deleting all the assets one by one starting with the game scripts until I ended up with only just the first scene. Still the Same leak(1mb increase each time I run my game). I don’t know what to do, Anyone out there can solve my problem?

I cannot attach the game, because I don’t want to give out all my codes or assets.

The Profiler resets when you Play, so what are you seeing there that suggests a leak? Perhaps post an image of what you think shows a leak.

Well, actually you said both show it. But anyway, it sounds like Unity (the editor) leaking, not your game. There is actually no such thing as a memory leak in .NET anyway, since garbage collection works by gathering up "leaked" (unreferenced) objects.

So you mean that with no objects in your scene, memory usage keeps rising over time? (a picture would make this easier...)

Good work! I'd be very interested to hear what their response is. :P Memory management is one of those "fundamentals"... If something's wrong there, you really need to worry. It's like when an engine starts drinking more oil than it should.

2 Answers

2

I have read a similar issue from another user who was intentionally allocating and deallocating and observing the memory behavior after their deallocation.

http://answers.unity3d.com/questions/153050/memory-management-and-list.html

Since he reported the same amount of memory leak after each execution, I suggested that he quit the game and checked if the memory was freed or not, but he performed a slightly different check.

So, have you checked that unity frees the memory or not after you quit it? I haven’t been able to reproduce the issue.

As a side note, I read that instantiated textures aren’t destroyed automatically. Does your scene perform any particular texture operations?

I actually believe this might be a bug now. I suggest you pack up your test project and report a unity bug. This doesn't seem to be automatically reproducible.

Memory not freeing after quitting Unity would be a bug in his Windows OS.

I'm pretty sure that if you have a memory leak in your application, it's not the OS's fault if there's less free memory after a program's execution :)

Many people have little understanding of memory management in a modern operating system. I'm still not convinced there is actually a leak happening, since you'd have to cause a 1MB leak 1000 times just to get to 1GB (and crash), and who has that little memory or that much time these days? Of course, some pictures would be more convincing.

I'd like to help document this bug since I kind of took part in reporting it, but I'm not entirely sure how to take a picture of a memory leak. :-/ Since a leak is identifiable by studying memory load over time, and an image is a snapshot, what kind of picture do you expect to see, to document a leak? I have a sample project with a test scene that I'd love to send to you, and you can see the leak take place in the profiler yourself, if you'll let me shoot it at your email. :) The entire project folder is 400kb.

The analyst replied after he ran the same empty scene, and confirmed that there is a 1MB memory leak. He assured that he will reply after talking with the devs.

2011 ... The analyst takes its time.

Okay I tried it now, but I see the problem isnt just canshoot bool, my recoil and muzzleflash can also play while reloading is on :(