Hey,
I currently try to do a project where I need to load many (small) images, around 10k in around 5 minutes - so I can’t fit them into memory at startup but need to (re-)load them during runtime - I thought that ofxThreadedImageLoader would be the proper tool for the job (yet I am still unsure as it seems difficult to figure out when an image is indeed loaded?)
Nonetheless, I tried to use it and I ran into a strange error when using this loader. Lets assume during setup I call this block of code
for(int i=0; i<2; i++) {
ofLogError(ofToString(dir.getPath(i)));
ofImage image = ofImage();
loadedImages.push_back(image);
}
imageLoader.loadFromDisk(loadedImages[0], dir.getPath(0));
imageLoader.loadFromDisk(loadedImages[1], dir.getPath(1));
which works fine but is a bit “verbose” when scaling up to 100 images. When I now try to put it into a for loop I get an error?
for(int i=0; i<2; i++) {
ofLogError(ofToString(dir.getPath(i)));
ofImage image = ofImage();
loadedImages.push_back(image);
imageLoader.loadFromDisk(loadedImages[i], dir.getPath(i));
}
where the error is
2eyes-ofDebug(8997,0x7000004f2000) malloc: *** error for object 0x11: pointer being freed was not allocated
2eyes-ofDebug(8997,0x7000004f2000) malloc: *** set a breakpoint in malloc_error_break to debug
2eyes-ofDebug(8997,0x7000004f2000) malloc: *** error for object 0x11: pointer being freed was not allocated
where ofxThreadedImageLoader imageLoader and std::vector<ofImage> loadedImages;.
I am still not fully confident with pointers and references, but this seems like a strange thing to happen? Shouldn’t both statements be quite the same?
2 posts - 1 participant