Please Help Please. Scene Loading Bug With Memory spike. I Don't know how to handle it

Hello, I am currently developing a puzzle game using DOTS.

It’s a game that requires a large number of physics calculations—anywhere from as few as 200 to over 6,000. This game absolutely needs DOTS.

I am currently using Unity version 2022.3.16f1 on Windows 11. I have 64GB of RAM (definitely not a RAM shortage). I’m using URP.

Please help me. I’ve tried everything I possibly can. If you have any ideas related to a solution, please give me even one. I will try them and share the results.

  1. I’ve read my code multiple times. There are no problems.
  2. Since it’s a puzzle game, multiple stages are needed. Even though the stages are exactly the same, simply changing the ‘order’ causes it to freeze.
  3. I’m certain there’s an error related to SubScene loading.
  4. I tried deleting the Global Entity Cache and Scene Dependency Cache, but the bug still occurs.
  5. I tried ‘Reimport All,’ but the bug still occurs.
  6. The current DOTS version is 1.2.4.
  7. The bug occurred in Entities version 1.0.16, so I upgraded to Entities 1.2.4, but the bug is still occurring.
  8. I tried deleting the Library folder, but the bug still occurs.
  9. Please tell me a solution…

I cannot remove DOTS.

Here’s what’s happening to me:

  1. starting certain stages in editor mode, the Editor completely freezes and a memory spike occurs while loading a SubScene in the Editor. The only way to terminate it is to ‘force quit.’
  2. After building the game, starting certain stages causes the game to completely freeze and a memory spike occurs. The only way to terminate it is to ‘force quit.’

The player loop is in a simple form:

Stage Selection → Stage Play → Connected Stage Play → Connected Stage Play → Stage Selection → Stage Play → Connected Stage Play

For SubScene loading, I am using the default SubScene provided by Unity. Within the scene, I create a SubScene and modify its contents.

If my explanation is insufficient, please let me know. If you have any ideas related to a solution, please give me even one. I will try them and share the results.

Use a sampling profiler like VTune, uProf, or Superluminal to see where Unity is stuck.

Thank you so much. I will check it out.

Some of the builds actually worked.
However, this is only possible on the ‘computer where the build was made.’
I have no idea why this is happening.

The computer used for demonstration and the computer used for building are different.

Computer for building—or development:

  • 64GB RAM, i9-13900H, RTX 4070 8GB - Windows 11

Computers for demonstration:

  • 16GB RAM, i7-7700, GTX 1060 6GB - Windows 10
  • 16GB RAM, i7-8750H, GTX 1060 6GB - Windows 11

Both Windows versions are updated to the latest version.

The build that works properly on the build computer does not work properly on the demonstration computers.

Accordingly, I thought it was an error with the Burst Compiler, so I changed the instruction set and rebuilt, but it wasn’t an error due to instruction set support of the Burst Compiler.
Also, all three computers support AVX2, AVX1, SSE2, and SSE4 for the Burst Compiler.

The next thing I thought of was existing save data remaining in the local files.
I deleted all of them.
I only deleted the files in the Local folder, but if there are any files remaining in other folders or paths, please let me know.

Additionally, the Windows user name is certainly in English.

Currently, I’m trying to check the situation with VTune. If you have any other ideas, please, please share anything! Even very trivial things, please tell me everything.

Thank you for reading this long message.
I really need help.

You should attach a debugger and use breakpoints to check where it is stopping.
For Visual Studio, this article might be helpful.

Thank you for reply

it twill helpful,
But, This is not the code stage. Also, lot time use the Debugger and stop for check it.
Maybe i’m wrong, but, i can’t find any error with my code.

Thank you for tell me that. if you have any other idea, please tell me.

DreamingImLatios

Thank you SOOOOO Much!!

Thank you so, so much!

During the profiling process, I discovered that a certain method was entering a while loop. I fixed it and resolved the issue.

Specifically,

In MonoBehaviour, I needed to create a Query Builder to determine how many entities currently exist. At that time, a specific entity needed to be more than zero, but since the SubScene was loading the scene asynchronously, the MonoBehaviour entered the while loop first.

The reason it worked on certain computers and not on others is that if the computing power is fast, the SubScene loading completes before the MonoBehaviour class executes.

Thanks to VTune, I was able to precisely locate where it was freezing and corrected the code. I sincerely, wholeheartedly thank DreamingImLatios for informing me of this. I had been struggling for over a month, but I was able to resolve everything. Truly, sincerely, thank you very much.