ofFbo deallocate?


I am using an ofFbo inside a class which I need to create and delete objects from. My problem is that calling myFbo.allocate() uses a bit of memory, but I cannot find a way of releasing that memory once I’ve finished with the FBO. Can anyone point me in the right direction?


You could store them in a vector and once you remove them they would be erased

You could also use a pointer

However allocating them up front is nice as reallocating will slow you down a bit

Thanks for the reply.

Storing the fbo in a vector still doesn’t seem to release the memory once the vector is cleared. Maybe I misunderstood but this is what I did to test that:

void testApp::keyReleased(int key){  
    ofFbo fbo;  

Allocating them up front might work but it means that I cannot delete the object which holds the fbo, so I have to reuse them without reallocating them. I would rather find a way of being able to create and delete the object at will as each fbo might need to be a different size.

Is there no way to simply release the memory that the fbo has taken up by allocating it?

Thanks again!

there is a fbo.destroy() but destroy() is called by the destructor so I am not sure why that wouldn’t fire with myFbos.clear();

It looks like destroy() is being called, it’s just not releasing the memory…

Correct me, if I am wrong, but doing anything different from changing some variables state inside all “events” called functions, is not a good idea, because they are not executed on the main thread. May be that’s your problem.


I’m wondering if there’s a way to deallocate an fbo now, as I’m running into the same problem that I need to constantly reallocate an fbo instance in order to change it’s size. I’m using it as an offscreen buffer, and throughout runtime images of different sizes need to be rendered onto it.

I’m having the same problems - using an fbo in a class to export an image when the class is created, but each time a new object is created from the class the memory creeps up and up to very high levels making the app slow down. If I remove the fbo stuff it’s all fine. I’ve tried putting the fbo in a vector and clearing it but seems to have no effect.

Is there any way to deallocate an fbo after use?

Have the same problem. I tested the problem with following code. Destroy is certainly called but Xcode tells me allocate is constantly eating memory.

void ofApp::update(){
  for (int i=0;i<100;i++){
    ofFbo dummy;
    dummy.allocate(200, 200, GL_RGBA);
    ofClear(255,255,255, 0);

Seems this call is the source of problem.

Hi. I can see this thread is very old, but it might be worth resurrecting it.

I have seen this same issue.
I have a class that might discard an fbo once it is done using it. But the memory never gets deallocated. Over time, the memory piles up.

Has anyone found a proper way to free the memory allocated with ofFbo.allocate?


1 Like