Memory leak with Mat in convertTo-function

前端 未结 1 552
旧巷少年郎
旧巷少年郎 2021-01-24 07:23

I have some trouble with managing memory in my function. Valgrid says I\'m having a memory leak after the convert-function. Could it be because of the data is not being properly

相关标签:
1条回答
  • 2021-01-24 07:58

    please don't store pointers to Mat in your vector(or anywhere else !).

    those things are refcounted internally, like smartpointers, and you're wrecking that by storing/copying pointers (a vector of pointers to smartpointers would sound silly anyway, no?).

    use a plain vector<Mat>, trade some additional ~56 bytes per item against sound sleep tonight ;)

    0 讨论(0)
提交回复
热议问题