voxeltycoon / issues

18 stars 4 forks source link

[MacOS] Increasing memory usage - leaking Mach ports #918

Closed ghost closed 1 year ago

ghost commented 2 years ago

Describe the bug Voxel Tycoon leaks Mach ports and the process consumes more and more memory over time until it runs out of resources. The memory samples indicate a recursive function that may responsible for the increasing Mach port usage.

Steps to reproduce

Build version 0.87.0.3.steam

Platform macOS Monterey - Version 12.0.1

21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101 arm

Reproducibility every time

Logs/saves

thulme44 commented 2 years ago

I am experiencing the same issue with memory usage quickly going to 200GB+ on build 0.87.0.

Screenshot 2021-12-24 at 11 09 51

6

newyorrker commented 2 years ago

I have same issue on macOS Monterey 12.0.1

andrewpey commented 2 years ago

Please try this temporary solution: https://github.com/voxeltycoon/issues/discussions/924

ghost commented 2 years ago

@andrewpey Tested version 0.87.0.6 steam m1_test with a large map on a 2020 M1 MBP and it looks stable now. The memory consumption peaked at 9.2 GB, Mach port usage at ~800 which is significantly better.

andrewpey commented 2 years ago

@kristoffn Good to know, thank you! That build is made with an older version of Unity where the bug is not yet appeared. Unfortunately, it's hard to be considered as a good solution since it prevents us from using features and fixes which come with newer versions of Unity.

We have found a known Unity issue which might be related to this. We'll keep an eye on that and re-check when the issue will be resolved on Unity's side.

Also, if it's possible, can we ask you to try to switch to the beta_unity2021 branch and let us know if the issue is still there? it would really help.

ghost commented 2 years ago

@andrewpey Thanks for the update! Tested the beta_unity2021 version on a 2020 M1 MBP an the Mach port leak is gone. I think this issue can be closed. Thank you so much for the fix!

andrewpey commented 2 years ago

We've pushed the recent build with possible fix included to the beta branch. Please let us know if it's fixed!

ghost commented 2 years ago

With a medium-sized map, the real memory usage stayed around 1,3 - 2,1 GB. The binary used 45 threads and the Mach port usage stayed between 580 - 610.

I think this was the most stable build so far, there was no experienceable leaking Mach port or memory. From my end this issue can be closed, let me know if you need the memory snapshots.

Thanks @andrewpey! :)

andrewpey commented 2 years ago

The fix is deployed to the main branch with 0.87.1.5 update. Thanks for your patience!

andrewpey commented 2 years ago

Seems like the issue is still here: https://steamcommunity.com/app/732050/eventcomments/3176733459032297101

andrewpey commented 2 years ago

We've just pushed a new build to the beta branch where we upgraded to the most recent stable Unity version (2021.3.0). Please try it out and let us know if the issue is still here.

andrewpey commented 2 years ago

We've just pushed a new build (0.87.1.8) to the beta branch which includes a native M1 version. Please try it out and let us know if the issue is still here (and if it works at all).

andrewpey commented 2 years ago

M1 players: We've just pushed a new build (0.87.1.11) to the m1_native_test branch. This build contains only M1 version. Please let us know if it works and if it has memory problems.

andrewpey commented 2 years ago

Here's another possible temporary solution found (see the Temporary solution 1): https://github.com/voxeltycoon/issues/discussions/924.

damianharouff commented 2 years ago

I tried the m1_native_test branch and still see memory usage escalating out of control. After about ~7 minutes or so, it's already up to 64 GB. My game is still on the default/starter/initial region, I can't really play long enough without the game crashing, to make significant progress to unlock other regions.

Sample of VoxelTycoon.txt

andrewpey commented 2 years ago

Thanks for the information. Can you try to change your game resolution to something other than your native screen resolution (or Looks like resolution if you use scaling) and see if this helps?

damianharouff commented 2 years ago

I believe I already have that set: I play in a window because I multitask while it runs, and the game is set for 3200x1800. My Mac is attached to a 4k monitor, which is set to a "looks like" of 1920 x 1080.

Let me know if there's anything else I can share!

Screen-Shot-2022-05-25-15-03-09

Screen-Shot-2022-05-25-15-03-36

damianharouff commented 2 years ago

I also just noticed that, while the "Memory" number for Voxel Tycoon is incrementing, it's not causing my Mac to swap, even though the "Memory" number is larger than the 32gb in this machine.

Screen-Shot-2022-05-25-15-09-50

damianharouff commented 2 years ago

Made a one minute video here showing the "Memory" value incrementing over time: https://link.cekkent.net/6e620454-74af-4745-97ad-4bc58ea6ecfc - also of note, the "Shared Memory Size" and "Private Memory Size" values intermittently change to huge numbers.

andrewpey commented 2 years ago

Thanks for the extra info, we'll continue to look into it.

LtDominator commented 2 years ago

This issue appears to still be presenting on Mac M1's, just fyi.

Screen Shot 2022-09-03 at 12 40 38 PM

andrewpey commented 2 years ago

This issue appears to still be presenting on Mac M1's, just fyi.

This is unfortunate, thanks for letting us know.

LtDominator commented 2 years ago

For clarification, after reading through other reports and suggestions, this is the main branch. Loading the Mac beta branch has solved the issue. Hopefully the main branch will see a fix soon enough so the most recent updates can be played!

damianharouff commented 2 years ago

@LtDominator are you using the one called "beta", or the one called "m1_test" ?

LtDominator commented 2 years ago

@damianharouff I am using, "m1_test - m1_test".

andrewpey commented 2 years ago

@LtDominator have you tried the beta branch with the 0.87.2.0 update?

LtDominator commented 2 years ago

@andrewpey I plan to play some later today, I'll test it and get back to you.

LtDominator commented 2 years ago

@andrewpey I played a new game using, "beta - Beta". I was able to play for nearly 30 minutes before I got the error again.

To note, in the main branch when I played it became more frequent as I progressed further and further in the game. Given how long it took this time, either this beta branch has an improvement over the main branch, or the memory leak is related to an instance of some sort that leaks and the more of those instances the faster the leak overflows my memory.

Screen Shot 2022-09-05 at 12 41 36 PM

andrewpey commented 2 years ago

Thank you for that extra information.

damianharouff commented 1 year ago

As we're ~1 year later, any movement or interest in engaging with this issue?

andrewpey commented 1 year ago

There's no new information unfortunately. We are waiting for the next Unity LTS release to upgrade (which should happen this spring), in hope that they've fixed something there.

andrewpey commented 1 year ago

The recent update (0.88.3.1) contains a possible fix for this issue. Please give it a try and let us know if it helps.

andrewpey commented 1 year ago

It seems that the issue is finally resolved.