Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Silicon Power on February 25, 2022, 08:36:38 PM

Title: Destroy object can't unload it from memory
Post by: Silicon Power on February 25, 2022, 08:36:38 PM
Hi. My game is an open world game and I need to load and unload objects because otherwise it uses too much of memory. Destroy game objects won't help it can't free up memory. ""Resources Un Load Unused Assets" action can free memory but it makes my game leggy.

Is there any action to unload only one game object from memory and not all unused assets?
Title: Re: Destroy object can't unload it from memory
Post by: djaydino on February 26, 2022, 11:16:24 AM
Hi.
If these objects are reusable you should look into pooling.

A different way is having a grid scenes system and load/unload scenes
Title: Re: Destroy object can't unload it from memory
Post by: Silicon Power on February 26, 2022, 05:23:18 PM
Hi.
If these objects are reusable you should look into pooling.

A different way is having a grid scenes system and load/unload scenes

No I need to load buildings from resources folder and unload when player is getting far from that building. Resource Load action can load but there is no action to unload that building again.
Title: Re: Destroy object can't unload it from memory
Post by: djaydino on February 26, 2022, 06:11:50 PM
Hi.
Resources Load (objects) Does the same as Create object, except its getting the reference from the resource folder.

If there are many object that can be reused you might be able to create pools, after you got it from resources load.

But i think loading/unloading scenes (depending on player position) will still be better.
Title: Re: Destroy object can't unload it from memory
Post by: Silicon Power on February 26, 2022, 06:23:20 PM
Hi.
Resources Load (objects) Does the same as Create object, except its getting the reference from the resource folder.

If there are many object that can be reused you might be able to create pools, after you got it from resources load.

But i think loading/unloading scenes (depending on player position) will still be better.

I tried load/unload scene too but even unloading a scene doesn't  free up memory :'( The only action that works is "Resource Un Load Unused Assets" but it makes the game leggy because it unload all unused assets at once.
Title: Re: Destroy object can't unload it from memory
Post by: djaydino on February 26, 2022, 07:15:18 PM
Hi.
I'll ask to someone i know that uses this system how he handles memory.
Title: Re: Destroy object can't unload it from memory
Post by: Silicon Power on February 27, 2022, 03:02:38 PM
Hi.
I'll ask to someone i know that uses this system how he handles memory.

Awesome thank you a lot.
Title: Re: Destroy object can't unload it from memory
Post by: 600 on March 24, 2022, 04:36:45 AM
Hello,

Djaydino pointed me to check this thread.

Indeed there are issues with unloading and using the unload all unused assets made some players experience crashes even when used in unnoticeable spots like during menu loading or similar. Also the frame drops as you mentioned if used on regular basis was not acceptable.
I went for additive scene loading for buildings and it helped for overall experience, still to polish it, but since buildings tend to repeat in areas all do not have to be unloaded.
It may be different on your project, but maybe we could request new action to unload specific asset https://docs.unity3d.com/ScriptReference/Resources.UnloadAsset.html