Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by peter8989 · Aug 17, 2011 at 12:18 AM · memoryprofilerstuckmemory-leakleak

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.

Comment
Add comment · Show 8
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Waz · Aug 17, 2011 at 12:43 AM 1
Share

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.

avatar image peter8989 · Aug 17, 2011 at 01:59 AM 0
Share

as I said, the task manager also shows an increase in private memory. Unity crashes when the allocated virtual memory reaches maximum, in my case it crashes when the memory exceeds a certain value every time.

avatar image Waz · Aug 17, 2011 at 02:22 AM 0
Share

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.

avatar image CHPedersen · Aug 17, 2011 at 07:20 AM 1
Share

I'm the guy who posted the other question reporting this issue. ;) Like @peter8989 says, the 1mb leaking is definitely associated with the editor. I made a build of the testscene I described in that Question, and the build doesn't have a 1mb leak/run when consecutive runs are observed in the Task $$anonymous$$anager. The 1mb leak/run takes place in the Profiler when run in the editor only, so there is definitely something the profiler is not resetting properly.

$$anonymous$$y original question in this regard was two-fold, though: I added plain integers to a list and then called Clear and TrimExcess on the list in an attempt to free the allocated memory. This did not cause the allocated memory to be freed as expected; it was observed to maintain its memory usage both in the profiler and in the task manager when running builds. This means the second part of my question is likely a bug in $$anonymous$$ono.Net'a GC.

avatar image peter8989 · Aug 18, 2011 at 08:36 PM 1
Share

well, i did read your post. Reported this issue to Unity Support with the empty scene I'm getting the leak. Hope to get an answer soon, and will report whatever I hear from them.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by roamcel · Aug 17, 2011 at 05:29 AM

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?

Comment
Add comment · Show 12 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image peter8989 · Aug 17, 2011 at 06:14 AM 0
Share

it does free the memory, the memory always starts at the same value in my case. I even restarted the computer lol. same result!

avatar image peter8989 · Aug 17, 2011 at 06:15 AM 0
Share

but its kinda weird, those two people said they were having the same "1$$anonymous$$B" problem too, seems like a UnityGC bug perhaps?

avatar image roamcel · Aug 17, 2011 at 08:08 AM 0
Share

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.

avatar image CHPedersen · Aug 19, 2011 at 11:32 AM 1
Share

It is. :) Warwick is totally right, here. Remember that a program's allocation of any kind of resource is at the mercy of the OS. Whenever you write "int i = 0", your runtime system runs like a well-trained schoolboy to Windows and says, "Can I have 32 bits, pretty pleeeeease?". That's why unmanaged code written in C and C++ sometimes throws pesky AccessViolationExceptions if you attempt to write to unallocated memory - this is actually the OS telling your program to back off and $$anonymous$$d its own business, because it tried to write into areas of memory reserved by the OS, and it refused your program access. Because the OS is the authority when it comes to GRANTING your program resources, it is also responsible for cleaning up AFTER your program has finished execution. Leaks made by your program manifest while the program runs. Not afterwards.

avatar image Waz · Aug 19, 2011 at 12:47 PM 1
Share

In your List question, you appeared to believe that allocating a load of memory and then freeing it should result in the memory usage shown in the Task $$anonymous$$anager being unchanged. That might seem intuitively obvious, but it is not true. Programs allocate large chunks from the operating system, then manage handling little 4-byte ints etc. themselves, merely marking something as free (but not necessarily handing it back to the OS). When you think you've just done 100,000 allocations and deallocations, what makes you certain Unity hasn't allocated 4 bytes amongst that for something else (meaning the entire block cannot be reallocated, even if it happened to somehow all be in a new fresh block)?

I am not saying that there is no leak, I'm saying that all the evidence I've heard makes invalid assumptions about memory allocation.

If you go back one step further, you'll see that the "1$$anonymous$$B texture taking 2$$anonymous$$B!!" was also a result of invalid assumptions about memory.

Certainly even a real leak of 1$$anonymous$$B that only happens in the Editor once every Play is rather irrelevant (once people have learned that the OS discards all allocations upon process ter$$anonymous$$ation). If Unity stays running long enough to hit Play 1000 times without freezing or crashing, it probably shows some EasterEgg for all we know...

Show more comments
avatar image
0

Answer by peter8989 · Aug 21, 2011 at 09:40 PM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image __maja__ · Nov 22, 2015 at 04:09 PM 0
Share

2011 ... The analyst takes its time.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Performance going down over time 2 Answers

Mesh Destroy After an Editor Stop 0 Answers

m_Memory.renderTextureBytes<0 1 Answer

ManagedHeap.ReservedUnusedSize 0 Answers

0 or Blank Ref Count Items in Memory Profiler 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges