C++ threw an exception which means the destructor for variables in bsgm_prob_pairwise_dsm::process/compute_min_max_disparity_from_height doesn't get called right away. Instead it stays on the heap for a while, meanwhile the python wrapper object for bsgm_prob_pairwise_dsm gets collected in a python exception traceback frame, keeping the ref count at one never allowing bsgm_prob_pairwise_dsm to be garbage collected. When the executor context ends, all this memory would have freed up, however if you run out of memory before that, it all fails.
The solution is to just clear the frames of the tracebacks, and the only universal method I could find to do that was by adding a callback function to the Future object.
This will unfortunately make attaching a post mortem debugging for an exception in a task harder, But normal set_traceing will still work as intended.
Finally tracked down a solution to the leak
C++ threw an exception which means the destructor for variables in
bsgm_prob_pairwise_dsm::process/compute_min_max_disparity_from_height
doesn't get called right away. Instead it stays on the heap for a while, meanwhile the python wrapper object forbsgm_prob_pairwise_dsm
gets collected in a python exception traceback frame, keeping the ref count at one never allowingbsgm_prob_pairwise_dsm
to be garbage collected. When the executor context ends, all this memory would have freed up, however if you run out of memory before that, it all fails.The solution is to just clear the frames of the tracebacks, and the only universal method I could find to do that was by adding a callback function to the Future object.
This will unfortunately make attaching a post mortem debugging for an exception in a task harder, But normal
set_trace
ing will still work as intended.