Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
0
Question by bills801 · Aug 17, 2021 at 10:04 PM · profilerwindows 10memory-leakprofiling

Memory leak but only in the executable

I am having an issue with a memory leak that only happens in the compiled game. I have tried using the memory profiler and it gives me the same memory usage for each capture. It is not showing the leak. I have also tried using the main profiler which shows Total system memory usage at 2.21G and growing but does not show it anywhere in the details. The game will crash after about 24 hours. I have done a lot of looking online but I have not found anything that might help me track this down. Is there another way to find what is causing this or at least point me to an area?

Comment
Add comment · Show 2
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 bills801 · Aug 18, 2021 at 02:17 PM 0
Share

Update: So Since I am a noob at some of this I will add in what I have found for other noobs.(I think my assumptions are correct) in profiler I clicked on the memory square next to the graph. This displayed the simple stats where I can see that the 'Total System Memory Usage' is increasing. The last line shows 'GC Allocations per Frame'. I noticed this number seems quite large for the scene that is not currently doing anything(no animations or activity). It is running between 30k and 150k per frame. Next i clicked on the CPU Usage square at the top and in the bottom section sorted by GC Alloc and started drilling into the highest value which is giving me the routine that is generating all of the GC Allocation. Looking at the script I am not seeing the issue(so far). I changed a few places where I pass a string to pass as reference but that did not help. Still looking.

If any of this is incorrect on how to chase this down, please correct.

avatar image bills801 · Aug 20, 2021 at 01:38 PM 0
Share

The process that i have done so far only pointed me to some code that I could have done better. In that script i was doing some string concatenation that was causing excessive GC. Fixing that reduced it considerably but it did not fix the leak. After going through the code for about seven hours I finally decided to do a side by side comparison with my development system and the production system. The development system is Windows 10 Ent. and the production is Windows 10 IoT. The Exe runs with no leaks on the dev machine but has a severe leak on the IoT machine. IoT is a enterprise with some stuff not installed and I have disabled some services and applied some group policies. At this point I assume that Unity wants something that isn't installed, a service that is disabled or some setting that I have changed. Next step i am going to try is a fresh IoT install.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by bills801 · Aug 26, 2021 at 08:00 PM

Well, I Guess it isn't a Unity issue but it is the craziest thing i have come across in a while. If i start up windows and then click on the app, everything is fine. If I start the app using a task in task manager I get the memory leak. So far I have tried a few other ways to start the app on startup but none of them launch it.

Comment
Add comment · Show 7 · 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 Eno-Khaon · Aug 27, 2021 at 04:00 AM 0
Share

If you're launching it through another program, then you're inheriting various permissions from that other program (Ad$$anonymous$$istrator privileges, etc.).

Do you have information available on the differences between permissions between launching your Unity game yourself, vs. the program you're launching it from?

avatar image bills801 Eno-Khaon · Aug 30, 2021 at 12:38 AM 0
Share

After downloading and running Microsoft Debugdiag it is pointing to mono-2.0-bdwgc.dll. It is flagging mono_2_0_bdwgc!mono_marshal_string_to_utf16+beb. I have no idea if it is an issue in the dll or if it is how it is called from the games scripts. From what the report is saying is that this is what is leaking all of the memory.

Module Information

Image Name: E:\MonoBleedingEdge\EmbedRuntime\mono-2.0-bdwgc.dll Symbol Type: Export Base address: 0x00000003`00905a4d Time Stamp: Mon Apr 12 08:56:12 2021
Checksum: 0x00000000`00000000 Comments:
COM DLL: False Company Name:
ISAPIExtension: False File Description:
ISAPIFilter: False File Version:
Managed DLL: False Internal Name:
VB DLL: False Legal Copyright:
Loaded Image Name: mono-2.0-bdwgc.dll Legal Trademarks:
Mapped Image Name: Original filename:
Module name: mono_2_0_bdwgc Private Build:
Single Threaded: False Product Name:
Module Size: 7.43 MBytes Product Version:
Symbol File Name: mono-2.0-bdwgc.dll Special Build: &

Top 5 functions by allocation count

mono_2_0_bdwgc!mono_marshal_string_to_utf16+beb - 677,786 allocation(s) mono_2_0_bdwgc!GC_malloc_uncollectable+58cd4 - 2,659 allocation(s) mono_2_0_bdwgc!GC_malloc_uncollectable+58e0f - 1,167 allocation(s) mono_2_0_bdwgc!GC_malloc_uncollectable+7095 - 05 allocation(s) mono_2_0_bdwgc!mono_valloc+4c - 03 allocation(s)

Top 5 functions by allocation size

mono_2_0_bdwgc!mono_marshal_string_to_utf16+beb - 337.41 MBytes mono_2_0_bdwgc!GC_malloc_uncollectable+7095 - 4.98 MBytes mono_2_0_bdwgc!GC_malloc_uncollectable+58cd4 - 473.06 KBytes mono_2_0_bdwgc!mono_valloc+4c - 192 KBytes mono_2_0_bdwgc!GC_malloc_uncollectable+58e0f - 144.67 KBytes

Function details

Function mono_2_0_bdwgc!mono_marshal_string_to_utf16+beb Source Line
Allocation type OLE/COM allocation(s) Allocation Count 677786 allocation(s) Allocation Size 337.41 MBytes Leak Probability 100%

avatar image Eno-Khaon bills801 · Aug 30, 2021 at 02:55 AM 0
Share

Well, this *does* seem to indicate that it's almost, if not entirely, the garbage collector that's leaking memory.

Based on your testing, hardware/platform dependency for the rate that memory leaks unfortunately lands this beyond the scope where I can offer useful advice.

This is more the sort of case where you will need to try and bring it to the developers' attention as best as possible, even if that means as little as a Bug Report.

Edit: More importantly, this is good information to get out there, so the more detailed analysis you can gather right now, the better.

Show more comments
avatar image bills801 · Aug 27, 2021 at 02:18 PM 0
Share

I did a test where I set a 1 $$anonymous$$ute delay on the task and restarted. The game still leaked. Next I just right clicked on the task and told it to run. Still leaked. Ran the exe Directly. No leak. I then cleared some of the task settings and tried again. Game leaked. Unchecked Run with highest privileges and it doesn't run at all. When I installed Windows I forgot to set the Game to run as ad$$anonymous$$ and I get errors in debug. After setting the game to run as ad$$anonymous$$ I do not get those error in any attempted launch configuration.

Current settings: Game is set to run as Ad$$anonymous$$ for all users.

Task: General Tab: The Run user account is an Ad$$anonymous$$istrator, Run only when when user is logged on, Run with highest privileges, Configured for Windows 10

Triggers: Begin Task at logon, any user, Delay task 1 $$anonymous$$ute, enabled

Actions: Start a program, Game

Conditions: None

Settings: Allow task to be run on demand, Do not start new instance if running

Launch attempts: Starting from a batch file fails to launch, Starting from startup folder fails to launch, Starting from Registry Launches with leak, (HKLM:\software\wow6432node\microsoft\windows\currentversion\run), starting from powershell script attached to task launches with leak (Start-Process -Filepath "Game" -Verb RunAs), starting from Task launches with leak

avatar image bills801 · Aug 27, 2021 at 08:07 PM 0
Share

I downloaded Microsofts Degugdiag and ran it on the game. From what I am able to tell it is mono-2.0-bdwgc.dll. For some reason i can't get my crash report to upload.

avatar image bills801 · Sep 15, 2021 at 05:39 PM 0
Share

In the end, this is what i found. My app uses Sqlite with Unity. When connection to the database, either Sqlite or Unity is doing some manipulation with the path string. My configuration for deployment has three logical drives. C is for the OS, D is for Data and E is used for the Program. With the Unity app files in the root of the E: drive the app would leak. While messing around trying to make sense of this I tried launching the app from different locations. i tried a folder on the desktop, a folder in D: and they all worked. I then deleted the files from E and copied the folder on to E and viola, no leak. I have now run the app for a week with no leaking.

avatar image
0

Answer by GeroNL · Aug 27, 2021 at 02:22 AM

Hello, Maybe you can check on the load session, like in a while, like instantiate, bust in particle or something like that.


And maybe you using preprocessor in wrong place/used, cause your case just in executable thing. reference : https://docs.unity3d.com/Manual/PlatformDependentCompilation.html


Hope it help.

Comment
Add comment · 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

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

128 People are following this question.

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

Related Questions

editor script memory leak 1 Answer

Memory Leak Help 2 Answers

Performance going down over time 2 Answers

Profiler.BeginSample() performance - does it affect it while not profiling? 1 Answer

"Real Memory" usage in iOS expands the more often one prefab is referenced in the assetbundle 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