Answer the question
In order to leave comments, you need to log in
How to solve memory leak in Unity3d for textures?
In Unity, it was necessary to convert the image from the camera to png and then send it over the socket. For this, RenderTexture was used and here is a piece of code.
byte[] RenderTextureToPng(RenderTexture rt)
{
Texture2D png_tex = new Texture2D(512, 512, TextureFormat.RGB24, false);
RenderTexture.active = rt;
png_tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
png_tex.Apply();
return png_tex.EncodeToPNG();
}
Answer the question
In order to leave comments, you need to log in
Solution:
https://forum.kerbalspaceprogram.com/index.php?/to...
It was a constant announcement
Although I still do not fully understand why it is not removed by the garbage collector ..
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question