Closed tianqi1994 closed 10 months ago
Did the profiling tool give any more info about the increased memory?
Did the profiling tool give any more info about the increased memory?
I'm sorry I didn't find any information,
public static void OpenPhoto(Action
I have a theory. That's memory that will be collected by Android's native garbage collector. The memory footprint comes from the camera Intent and the Fragment created by NativeCamera. If my theory is correct, then the memory usage should drop back to normal levels after launching NativeCamera a few times. Otherwise, either the app will crash or it will consistently restart the Unity app after opening the camera a few times.
Yes, I just tested it and the unity app crashed after taking many photos in a row
I found that the problem is in the LoadImageAtPath API, if you do not call it, the memory will not grow
You said that you didn't do anything with the callback so I assumed LoadImageAtPath wasn't called in your test scenario. In this case, the loaded textures are increasing the memory usage. You should call Destroy(oldTexture) when you no longer need a procedural texture (one that is returned by LoadImageAtPath), otherwise it will continue consuming memory.
I have found my problem, I did not pass in the maxSize parameter, resulting in the default maxSize is the maximum value obtained, and it does not need such a large size in practical applications
Happy to hear that 🌷 In that case, I'm closing the Issue.
Just like the title says,When I opened the camera to take a photo, and then returned to Unity, I found that the memory increased by nearly 300M, however, I didn't do anything with callback in Unity, every time I opened the photo, it increased by nearly 300M, increasing all the time