[Bug] Having items manually assigned in a character's inventory before launching leads to Hash Value leaks

Ignatios

New member
Perhaps this is a known issue, but it's a pretty annoying one ;)

For testing purposes I have separate launch scenes with my characters set to certain levels/gear. This allows me to test projects at the beginning of the game or at late-game periods relatively quickly. However, I've noticed that when I assign items to an inventory, and launch several times from that scene, the hashes start piling up, eventually leading to an "out of memory" error (even when not playing). I'm not sure what causes this, but it's consistently happening. I've tried a few different configurations and it still happens (like changing when the inventory gets initialized, etc.).

I have workarounds for this, but it's problematic because there are a few points in the game where I have a character with specific inventory items that I'd like to keep that way, but if I run the game too many times, I have to load that scene with the character, empty their inventory from the editor, and refill it with the items I want.
 

Attachments

  • Screenshot 2023-08-26 112255.png
    Screenshot 2023-08-26 112255.png
    160 KB · Views: 3
I've never seen that before.

Could you send us the full error message (if there is one)?

Essentially you are saying adding/removing items to/from an inventory through the inspector creates residue data that does not get cleaned up and this causes the object to grow exponentially until it gives a memory leak?

I will add this to my list of things to investigate
 
Correct, I don't have a error message to report, it happens on a prefabbed object that has an inventory. If that prefabbed object exists inside the scene, and has items manually assigned to it, every time the game is launched, the hashes grow (and don't get cleaned up). I'm not doing any saving/loading in this circumstance either so it's pretty odd.

I have seen weird issues with prefabs + UIS in general. I've also seen prefabs get changes "applied" even though I never applied them. The same example is used with item categories or inventories. I'm not sure how this is all working in the background (nor do I care to ;) ) so I'm just reporting what I see (no errors or warnings appear).

ex: I have an `Equipment Panel` (created from UI designer) which has a `Item View Drawer` underneath it in a child object. This panel is inside of a Prefab GameObject. I changed the Category Item Views on the instance of that object which rests in a scene. When I changed the Categories (like switching Weapons to Consumables), the changes immediately appeared in my Prefab, and didn't stay only in that scene's instance, meaning the change appeared in all scenes that had that prefab.

I've seen stuff like this quite a few times when manually adding/removing items from an inventory, or in cases like the one I just mentioned.
I notice that most of the objects in the Demo scene from UIS are not prefabbed, and maybe all this weirdness is just from the nature of my project's setup, but I figure it's good for you to have word of it in case it does end up being a problem that other devs are reporting. Again, it might just be how my project is assembled.

Thanks for the notes though!
 
Hello, I encountered this issue today as well. As I was about to open the forum to report this bug, I came across a similar post, so please allow me to describe the problem I encountered in this thread. I believe it might be related to the issue discussed in that post.

1. When a prefab containing the Inventory script is nested within other prefabs or scenes, modifying the ItemCollections within the Inventory can result in explosive growth of serialized data in certain situations.

Here are the reproduction steps:
1. Create a prefab variant of the Player Character prefab in your demo.
1694690332357.png
2. Open an AttributeCollection for an item without making any changes to it.
1694690377261.png
3. Still without modifying the contents of the AttributeCollection, change the Amount of the item.
1694690430023.png
Check the size of the prefab variant, and you'll notice that its size has significantly increased, sometimes even up to 20 times larger than the original prefab.
1694690486980.png

2. When nesting an Item within an ItemDefinition, I also observed that the saved data size is incorrect, following a similar reproduction method as described above.

Therefore, I believe there is an issue with the way data is being saved, not only in the Inventory but also in other parts of the UIS.
 
We have a custom serializer for most of the data.
So my first assumption seeing this is that either we are saving duplicate data, or we are keeping outdated data in addition the the new data.
It's either that or Unity is also doing something in the background causing our serialized data to do weird things.

I will take note of your findings and I will look into it in more detail when I get the time
 
Top