I have a C++ object (Vision.cpp) that takes a bunch of images in its constructor. The object performs some image processing on these images and returns a result. This happens on the server side. The images were taken by the client side and sent over to the server as shown here:
Client takes image --> server receives image --> server instantiates Vision.cpp and passes in the sequence of images
The sequence of images, as expected, is heavy on memory. Should I design the Vision.cpp class to make copies of the images or should I just keep pointers to the images and force the server to not free the memory allocated for the images until Vision.cpp is done processing? I want to make copies to avoid forcing the server to keep its pointers valid, but image copying also takes time. Is there a good solution to this?