cv::Mat memory reallocation using push_back fails (Bug #4382)
Description
While successivly using push_back() from cv::Mat data may be lost when the matrix reaches a size somewhere above 4GB. At a given point, exactly at the same time when a resize of the matrix is performed, the resident memory shown in top drops from approximately 4.6GB to a approximately 0.6GB and the data gets invalid.
Interestingly one can make further push_back() calls without any problems. When the matrix reaches the point where the next resize of the matrix is required, i.e., at approximately 7GB, the resident memory flips back to the right size. The data, of course, remains invalid.
Here are some facts:
- System: Linux (Debian GNU Linux 8)
- OpenCV 3.0.0-rc1
- System memory: 16GB RAM
You should be able to reproduce this behaviour with the attached code example.
The critical lines from output are:<br/>
7960000: virtual 6069.54M resident 4768.39M<br/>
7970000: virtual 6069.54M resident 4774.32M<br/>
7980000: virtual 8396.09M resident 684.29M<br/>
7990000: virtual 8396.09M resident 689.96M
<br/>
... where the memory usage drops and:<br/>
11940000: virtual 8396.09M resident 2995.32M<br/>
11950000: virtual 8396.09M resident 3001.25M<br/>
11960000: virtual 11885.91M resident 7086.56M<br/>
11970000: virtual 11885.91M resident 7092.23M
<br/>
... where the memory usage flips back to the expected size.
I hope that helps to find the Bug.
Cheers,
Jens
History
Updated by Jens Garstka almost 10 years ago
- Status changed from New to Cancelled