pico-ssd1306 icon indicating copy to clipboard operation
pico-ssd1306 copied to clipboard

Potential memory leak for the buffer in FrameBuffer

Open zli117 opened this issue 3 years ago • 1 comments

The buffer in the FrameBuffer is allocated but never freed. This could cause memory leak if the SSD1306 is out of scope or a new buffer is set. Granted this may not be a very big issue since in most of the use cases SSD1306 lifespan will be the whole program lifespan. It's just that personally I think this still should be handled properly. Alternatively, instead of allocating the buffer on heap, just put it on stack, as the buffer size will always be 1024, and keep a member variable to point to member buffer or user-set buffer.

zli117 avatar Jul 10 '22 21:07 zli117

Oh yea I never considered this and assumed everyone would want their screens connected over entire program lifespan like you said. Definitely something to fix

Harbys avatar Jul 18 '22 09:07 Harbys