Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: misterjuly on February 24, 2023, 06:49:28 PM

Title: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly 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
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: djaydino 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).
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly 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!
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: djaydino 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
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly 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!
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly 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.
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: djaydino 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")
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: Christoph 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?
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly 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!
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly 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!
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: Christoph 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.
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly 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!
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: Christoph 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
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly 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.
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly 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!
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: Christoph on March 06, 2023, 11:15:09 AM
I'm definitely not the expert here but my gut says your good. I highly doubt that the behaviour is different on Windows. But due to the experience you had with your friend, better to check whatever you can.

I honestly believe that your game didn't had anything to do with the crash on your friends computer and that it just was a coincidence.
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on May 21, 2023, 12:01:13 AM
Well, my friend let me test it again on his computer and it happened again. My friend seems to think Playmaker is to blame somehow. Is this possible? I should note I tested the exact same build on a different windows system and it worked fine. The only difference I'm aware of is the fact that I uploaded the build on a different cloud service (my friend's didn't work on mega while mine worked on google drive). I doubt this has anything to do with it but I thought I'd mention it. Also, no scenes loaded asynchronously anymore. And it happened right as he started the game this time. Here's what his computer screen looks like afterwards. This is also a different project, but the same thing happened! I'm at a loss. Thanks for your help!
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on May 21, 2023, 03:19:01 PM
Now its not working on my pc. It froze it and then I exited out of it and its fine (it is a virtual desktop from my college), but the game won't run. (no data lost though). Just wanted to update you that it is probably a windows issue. Why won't my build work right on windows but will on Mac and linux? Thanks!
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on May 22, 2023, 07:52:57 PM
bump.
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: djaydino on May 23, 2023, 07:07:04 AM
Hi.
Have you tried making a build on a pc instead of mac (not a virtual desktop)?

it's very hard to say what the issue is, it can be many things
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on May 23, 2023, 12:26:35 PM
The problem is I don't have access to a pc myself (other than the virtual desktop) and I don't want to test it on someone else's pc for fear of messing it up. I noticed the results seemed fairly consistent across the Remote Desktop and the time it crashed my friend's computer. (mainly it sometimes working okay and sometimes crashing it). So my point is I think I can test what I need to test on the virtual desktop. Is there anything you would recommend testing specifically on the pc build? Thanks!
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on May 27, 2023, 10:39:13 PM
Bump.
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: Christoph on May 28, 2023, 10:01:33 AM
Take it to a office max or some internet cafe and install it there. Try out some 5-10 different computers (older and newer) and see if it crashes. If it does you definitely have a case.

At the same time maybe try as well with a clean project but built with the same machine. Does it crash too?

Then I would as well try to update playmaker to the latest and Unity to the latest lts. Does it still happen?

And if yes, start to dismantle your project. From big to small. Meaning, take out big junks of your game (delete FSMs or plugins) and test again. If you delete a part and everything works, you know the problem (probably an infinite loop) is in there. So start to go from big to small until you find the culprit. That’s how you debug.

Now, having said that, if it’s an infinite loop that causes this, you should see it as well in console in unity while in play mode. Do you effectively have no errors in editor?
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on May 29, 2023, 09:25:36 PM
No infinite loops that I'm aware of in the editor. It seemed to happen as soon as the project was loaded (and on two different unity projects). I would be scared to take it to office max because according to my friend, he had to reinstall windows. (I wouldn't want to be responsible for more damages, especially at a public venue). I can test it on a virtual pc from school without fear of damaging it (I think) because it is just a virtual desktop. Are there any logs or anything I could check? Where would those be? In the project folder? I'm not sure... But I do know that it has been (at least) a slight problem (but often a huge problem) on three PCs (my friend's, my friend's friend's, and my Remote Desktop). Is there anything outside the project that could make it work on Mac and Linux but not Windows (Unity version, files in different folders, DLL files, or anything else that I'm not thinking of.). Thanks again for your help.
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on June 03, 2023, 02:43:28 PM
bump.
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on June 06, 2023, 11:05:45 AM
bump again.
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: Christoph on June 06, 2023, 06:30:47 PM
I think we're all lost on how to help you. It's not normal what you are experiencing, that's for sure.

If I were you, I would try to start debugging step by step. Make an empty project, build, does the same thing happen?

Then use your own project, take a part out, build, does the same thing happen?

Step by step you will at one point be able to isolate the issue and find the culprit. I can't give more advice than that.
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on September 04, 2023, 08:40:34 AM
I think we might finally be on to something. @Christoph, I think you might have been right about the infinite loop thing.

See: https://forum.unity.com/threads/unity-bricks-computer-on-play.522907/

The question now is why does an infinite loop cause problems on a Windows build, but not a mac build. Surely I would have ran into the bug(s) he is talking about as he only played it maybe a few times while I’ve played it hundreds of times. Note this has happened for a variety of projects, so I’m not sure what to make of that. Is there a way to get unity/playmaker to let you know if there is a potential infinite loop BEFORE you build/start playing in the editor. Thanks again for all of your help and sorry if I have been annoying; I just really need to get this fixed. :)
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: djaydino on September 04, 2023, 10:23:22 AM
Hi.
As far as I know, Playmaker already has a checker for infinity and will disable the fsm if it reaches that. (by default 1000)

Do you have any other 3rd party assets running?
As it might not be playmaker related.
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on September 04, 2023, 12:39:03 PM
The only other thing, to my knowledge at least, is rewired and some custom actions (gotten mostly from the ecosystem browser, but it is possible some I downloaded online). I'm still stumped on why an infinite loop wouldn't affect a Mac, but could affect a PC regardless of editor or build. Do the different operating systems handle infinite loops differently in terms of if it crashes/bricks a computer or not? Or do you not think it is infinite loops, despite the link I previously linked? Thanks!
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on September 06, 2023, 06:26:56 AM
Bump.
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: djaydino on September 06, 2023, 12:41:17 PM
Well some part of could could be different.

in code there can be a #IF UNITY_MAC for example.
Then this code is for mac only.

also build process is different when build for pc on a mac or on a pc.

another thing is graphic cards one graphics card would have no issue while other have.

also older pc's vs newer.
We noticed on our game that old pc's with lower graphics cards have some weird behaviors compared to other pc's.

what you can try is install unity on a windows pc and make a debug build with profiler so you can see whats happening
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on September 06, 2023, 02:52:57 PM
Ok thanks! I’ll let you know if I have any more questions.
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on September 07, 2023, 11:51:09 AM
I THINK I have narrowed it down to the graphics cards being different on Macs vs. PCs. I don't know much about this subject, researched it, turned off the D3D11 swap chain settings and it doesn't seem to be crashing anymore (will have to do more testing to make sure), but the build is extremely laggy on PC but not Mac. I don't think it is the virtual desktop because it seemed to run the same when I was playing the game and doing other things on it. The reason I think it is the graphics card and not something else is because of this:

https://forum.unity.com/threads/constant-crashes-failed-to-present-d3d11-swapchain-due-to-device-removed.987834/page-2

Note that I never tried it on anything below Windows 10, and according to this, I think that is more evidence that this is the problem.

So here is my question now: What can I do to make it run better on PC? Not general things like performance in making the game, but things that are specific to PC, or more specifically, the graphics cards within. I tried a few things within the Project Settings, but if anyone could give me a list of things that could be helpful, I would be extremely thankful. Remember, it runs fine on a much weaker MacBook Air than a powerful PC. Also, please let me know if any of my reasoning is not sound. Thanks!

 
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on September 09, 2023, 01:42:33 PM
bump
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: misterjuly on September 11, 2023, 08:59:50 AM
bump
Title: Re: Memory Leak causing lots of data loss to friend's computer
Post by: djaydino on September 11, 2023, 12:16:52 PM
Hi.
Update to the latest unity lts version.