How to fix RAM increasing from creating textures

I have a method that uses readpixels to create a texture and assign it to a material
I am using MaterialPropertyBlock.SetTexture to set it
each time I run the method the ram increases by 10Mb
Even though I am always overwriting the same property block

I think all these textures arent getting unloaded/Destroyed?

Everytime I run the method I dont need the old textures, only the new one

Can someone give me some advice on how to proceed?

What are you doing with the old texture?

Texture’s are created in unmanaged code. They must be destroyed to be cleared out of memory.

nothing at all, i iwill investigate this problem thankyou

It’s also possible that if you feed a texture into this endpoint, perhaps Unity makes a copy.

If so I would expect that your previous texture injections would simply be lying around without any references and therefore be eligible for UnloadUnusedAssets() cleanup, which of course fires automagically when you change scenes.

If you call UnloadUnusedAssets() after setting your new texture, does the leak still occur?

I will try this aswell, thanks