简体   繁体   中英

glReadPixels() memory leak in opengles?

I encounter glReadPixels memory leak issue.Please See the image attached 屏幕截图

notice the area marked with red lines.malloc free pair memory is OK,but an extra 3M memory is allocated by glReadPixels, I have read from doc glReadPixels official doc

which has not mentioned any mem alloc information by glReadPixels. So,does glReadPixels really allocate memory.If so, how to free it?

Seeing the amount of memory increase during a single call is far from conclusive proof of a memory leak. There are many scenarios where the reported free memory will not go back to the original values, without there being anything wrong. For example, as @derhass already suggested in a comment, the driver could be allocating a buffer that it has not freed yet, or is intentionally kept around for later reuse. Depending on how memory usage is measured, it could also be the memory management system that does not return pages to the OS when memory is freed, but keeps them for future allocations.

If you want more conclusive data, you need to repeat the operation. Try doing the same thing a few 1000 times in a loop, and watch the memory usage over time. If it gradually increases, you have reason to believe that there might indeed be a memory leak. It can be best to draw a plot. If memory usage increases initially during a stress test, and then flattens out, chances are that everything is fine. If it linearly increases across the entire test run, there's a strong case for a memory leak.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM