Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Will this code cause a memory leak?

$
0
0

@cuinjune wrote:

in ofApp.h

 unique_ptr<ofImage> myImage;

in ofApp.cpp

void ofApp::draw(){

myImage = make_unique<ofImage>();
myImage->load("image.jpg");
myImage->draw(0,0);

}

I know the memory allocation and the image loading part can be called once in setup()
But let's say I wrote this way, will it cause any memory leak?
I learned that smart pointers don't need to be deleted, but I also read somewhere it can be deleted using 'reset'. http://stackoverflow.com/questions/25609457/unique-ptr-explicit-delete

When I run the code in Xcode, the memory seemed to be gradually increasing although I'm not sure if it's a leak.
Can anyone clarify this for me please? Thanks in advance!

Posts: 6

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles