Application.Shutdown.CleanupMono never finishes.

This problem persists in version v.2022.3.19f1

In my case, it has something to do with the number of gameobjects in the scene.

If my scene has few gameobjects then the application quits properly, but if the scene has many objects then it freezes when I call Application.Quit

This is what I get on Player.log :


[ALLOC_TEMP_TLS] TLS Allocator
StackAllocators :
[ALLOC_TEMP_MAIN]
Peak usage frame count: [256.0 KB-0.5 MB]: 256 frames, [0.5 MB-1.0 MB]: 439 frames, [1.0 MB-2.0 MB]: 1 frames, [4.0 MB-8.0 MB]: 3 frames
Initial Block Size 4.0 MB
Current Block Size 6.5 MB
Peak Allocated Bytes 6.5 MB
Overflow Count 0
[ALLOC_TEMP_Background Job.worker 4]
Initial Block Size 32.0 KB
Current Block Size 32.0 KB
Peak Allocated Bytes 54 B
Overflow Count 0
[ALLOC_TEMP_Loading.PreloadManager]
Initial Block Size 256.0 KB
Current Block Size 504.0 KB
Peak Allocated Bytes 486.6 KB
Overflow Count 53
ā€¦
[Many blocks like this]

Any ideas on this?

1 Like

Problem still exists!

1 Like

I have just found a workaround:
When the exit button is pressed in my game, the main scene executes:

yield return SceneManager.UnloadSceneAsync(0);
GC.Collect();
SceneManager.LoadScene(1);

Then, a new empty scene is loaded with just a script that calls Application.Quit() on the Start method.
Remember to add the new scene to the ā€˜Scene In Buildā€™ list in the Build Settings.

try to delete this folder:
C:\Users\yours\AppData\Local\plastic4

1 Like

Still see this bug on Unity 6.0000.0.23f1(LTS).

Work for me, thanks!

Even with Unity6

worked, thanks!

Still seeing this in 6.34

No localization pkg installedā€¦

Please file a bug report. There are many things that can cause this issue, we will need a reproduction project so we can identify what is causing it for you.

As you said there can be multiple ways to cause this issue, I donā€™t have much hope in truly making this issue go away. Unless Unity restructures the way it shuts down to make this impossible to happen. (Having the Rider IDE open can sometimes be an easy way to repro)

So thereā€™s an easier way to deal with this:

In Windows 11, you can enable the ā€œEnd Taskā€ option in the context menu when right clicking the Unity icon on the task bar. This saves you the trouble of opening the task manager to look for Unity.exe which can sometimes be buried under Unity Hub.

Hereā€™s a link with screenshots describing how to do this: This hidden Windows 11 setting adds an 'End task' option to every task on your taskbar | ZDNET

tl;dr: Windows Settings ā†’ System ā†’ For developers ā†’ Enable ā€œEnd Taskā€

Yes I will try to reproduce it in a small project. It doesnā€™t happen in an empty Unity 6.34 project but it does for our game.

Also it doesnā€™t always happen. But when it does and it blocks / stops the internet from working I tried leaving the editor running for an hour to see what happens. It will slowly take up more and more memory until maxing out avaliable RAM. So it seems like some process is trying to run and maybe using up all the resources, bandwidth, etc, not sure. Just some observations - but will continue trying to reproduce it.

I downgraded to Unity 6.24 and it stops happening.

Seems to happen in 6.32, 6.33, 6.34 when I install this asset.

It happens cause it tries to fetch a version file from github and is unable to or something so it keeps retrying or uses up all the available network ports. I didnā€™t fully debug it but itā€™s reproducible when installing this asset in 6.32+

When I downgraded back to 6.24 the asset doesnā€™t cause this issue. So I assume something must have changed in some of the unity updates to allow all the outbound ports to be used up. This also explains why existing tabs and network connections donā€™t get impacted, while new tabs and connections are unable to connect to the internet.