playMaker

Author Topic: Memory Leak causing lots of data loss to friend's computer  (Read 3477 times)

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Memory Leak causing lots of data loss to friend's computer
« on: February 24, 2023, 06:49:28 PM »
Hello,

I sent a friend of a friend's a copy of my build. When he ran it, it gave him a memory leak, he lost a lot of data (unrelated to the game) and had to reinstall windows. Not good. What could have caused this? The only thing I can think of is I am loading scenes asynchronously and not unloading them. Could that cause that much damage? Thanks!

John Bassi

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #1 on: February 25, 2023, 06:52:53 AM »
Hi.
it causes your memory become full and crashes your computer, which could damage windows program, but it should not damage stored files.
He could probably have used windows repair.

if you are loading scenes and not unloading that can indeed fill up your memory and give more/other issues (as you have duplicate scenes).

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #2 on: February 25, 2023, 02:21:57 PM »
The weird thing is I’ve tested it countless times on my Mac and it works fine but he seems to have problems with it on Windows. What is the problem with windows? Why would it work on my Mac and not windows? Could the linker wizard also play a factor. He hasn’t tested after losing data and doesn’t really want to (and I don’t blame him, I wouldn’t want to risk data on my computer either). It’s just weird. Thanks!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #3 on: February 25, 2023, 02:33:19 PM »
Hi.
He might have only a low memory capacity and maybe played for a longer time in 1 session.
Linker wizard only makes sure that certain scripts are included in a build. so I don't think that this would cause any issue.

on pc you can check your memory during playing by opening 'task manager'

on mac you can try to check this way :
https://eshop.macsales.com/blog/81567-how-to-check-mac-memory-usage/

play the game (best in a build) change scenes and see if memory is growing and not decreasing

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #4 on: February 25, 2023, 09:23:27 PM »
He said he did lose some actual files like videos, art, and passwords. Is there anything else that could potentially cause this? I know you said he shouldn’t have lost data but he did so I want to get to the bottom of this so it never happens again. Thanks!

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #5 on: February 25, 2023, 10:04:14 PM »
He also said that windows repair wouldn’t work for him. Just wanted to give you that little bit of information too.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #6 on: February 26, 2023, 01:02:42 AM »
Hi.
if he reinstalled windows and the files where on the c drive (never save data on the same drive as your operating system), they might be deleted cause of the reinstall.
Not because of the crash itself.

there are some tools that can still get those data if they are not overwritten
(try search for "recovered deleted files")

Christoph

  • Beta Group
  • Sr. Member
  • *
  • Posts: 254
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #7 on: February 27, 2023, 06:20:13 PM »
Interesting and sorry for your friend. How do you unload data loaded from a Resources folder? And aren’t they just cached rather than loaded into memory?

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #8 on: February 28, 2023, 05:41:56 PM »
I'm really not sure. Here's some more information from him: "A blue screen followed up with the windows logo, then the computer would just loop over and over again.". I'm not sure what caused this. djaydino said that it should not damage stored files. Is there anything else that I could be doing that could make you lose stored files? Any other bad things to do. I can send someone the game via private message so that they can analyze it if anyone would be willing to. Thanks!

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #9 on: March 02, 2023, 09:56:28 AM »
Just make sure if you do, to make a backup of ALL of your computer in case something goes wrong. Thanks!

Christoph

  • Beta Group
  • Sr. Member
  • *
  • Posts: 254
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #10 on: March 02, 2023, 01:04:52 PM »
I read up a bit more about loading and unloading because I clearly am missing some crucial information here as well. I don't use scenes though, only prefabs. I wonder now what happens once you load them into memory and then close the game. Will it be in memory until the OS unloads by force?

And I also read that in fact all game objects, materials, textures etc are being load into memory as soon as you use them (for example at scene loading). So it's not a matter of using load actions or not. Loading only is a way to, well, load them at specific moments where it's convenient for you (or not load them at all). But once you loaded them automatically or through a load action, it will stay there in memory. And I guess, it's Unity that decides to get rid of it through garbage collection (correct me here if I'm wrong) whenever it's necessary.

Unloading (the action) seems only will work if you first get rid of all references in the game. Meaning even if you have a reference somewhere else to your scene, it won't be able to unload it. Same for materials, textures, etc So in most cases, unload won't do anything.

In this regard, to your problem, I am with djaydino here, I don't think that your game was capable to 'destroy' your friends computer in this way. The only possible thing that could have happened is that your game filled up the memory (like Internet browsers do for example, just way quicker) and that this ultimately lead to a crash. If with this crash the harddrive got damaged it's more so that the harddrive already had a problem and by sheer bad luck it happened at that very moment.

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #11 on: March 02, 2023, 01:41:01 PM »
That's reassuring. Though I would still prefer someone look at my project to make sure it is truly okay. Is that why scene unload async actions give me an error most of the time? Or is it because I am unloading scenes that haven't been loaded yet? If it is not a scene-loading issue, how do I get the RAM to not fill up on the computer so quickly?  Thanks!

Christoph

  • Beta Group
  • Sr. Member
  • *
  • Posts: 254
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #12 on: March 02, 2023, 09:52:49 PM »
Did you confirm that it’s actually doing that as djaydino said in his first reply?

Also check out this link:
https://unity.com/how-to/use-memory-profiling-unity

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #13 on: March 04, 2023, 06:36:41 PM »
It is going up to like 700 mbs when the level is loaded, but goes down to something like 200 or 300 mbs when it is not loaded. Is this okay? I added the unload actions, so maybe that helped. I'm going to try a build without those actions to see if it still goes down. I'll update this and let you know.

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Memory Leak causing lots of data loss to friend's computer
« Reply #14 on: March 04, 2023, 06:52:37 PM »
It still went back down without the unload scene actions. It might be overall 100 or 200 mbs higher, but nothing that should impact it that badly. Any other suggestions? I can try to test it on Windows computers. Would that make a difference potentially? Thanks!