|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
+ w& {5 s' c# s) ^我是在ARM上运行的,我的测试代码如下:
% o( ^9 b) Q' \0 z/ P5 D: O6 y- v3 I9 s) }7 h% G8 ?
#include<stdio.h>! w: W" U; k% U7 V# X1 \
#include <opencv2/opencv.hpp>; `& U8 E# G1 f% {
#include <opencv2/contrib/contrib.hpp>
, G; ^7 U; g2 u3 T#include <string>7 A9 [1 E+ ^1 S/ b2 [, Y# c! a
- ?0 S2 O& x5 W" G) w0 L4 q0 eusing namespace cv;1 W ~: b1 J* N* k
using namespace std;
& B6 e5 w" X/ @3 h; B
. E# O% t- i% E: w, g/ g8 ]int main(int argc ,char* argv[])
; M& l: f: @5 j8 o4 G) b{
v3 H, p1 h( S$ v+ S* V" I- Svector<Mat> matVec;
- ~- J0 m+ K* v3 ~3 S0 Y$ Q" u//Mat tmpMat;9 ^/ ]+ @/ U8 S4 v: B
IplImage* src;* B# k& G) V# H
' ]5 t5 ^7 R9 t7 W& g! Lfor(int i=0;i<100;++i)
3 P5 ] g3 Q4 J' z{. d2 Y8 O Z. \/ `) ]/ F
Mat tmpMat;
4 Z, u6 ~& c' T% j9 W8 X% f) ? tmpMat.create(cvSize(256,256),CV_8UC1);
; K, _* I9 F# a7 M for(int j=0;j<256;++j), x, @$ g$ Z' H+ i
for(int k=0;k<256;++k)
2 Y1 X- ^6 v- }* u- L5 @& y9 C {! C6 s8 \& e+ W+ g/ i5 g5 l
tmpMat.at<uchar>(j,k)=(i+j)%255;, l* [$ H& }$ n
}
" \& ~# J9 y0 P' E" q8 a matVec.push_back(tmpMat.clone());8 o' x& \9 d z
}
7 w" | O" l5 Aint index=100;) A9 t& a8 m" ]9 N# W2 `% a' N
system("free");
: j k' C9 a* E: A* Oprintf("Press any key to stop!");
0 j0 h M! p7 s9 q& s4 Fgetchar();5 Q1 ]' v0 i0 N! b8 P4 |) v* m5 e0 y
while(index>1)
. P0 X5 ]5 c* }$ f {
/ w6 I; L2 m7 I+ p5 b matVec.at(index-1).release();0 q+ s; c0 {' B2 a0 o) M
--index;! N' H8 D6 r5 K- S! g3 x' I* u3 y
}0 z7 I* f' y7 @) A, M, h- p: Y
matVec.clear();% _, `2 q0 b# ^5 N( J: y4 M
vector<Mat>(matVec).swap(matVec);; f+ X' ~6 v( ]
system("free");4 E! C( v, o+ |6 q8 y3 r
printf("Press any key to stop!");
+ I; [3 p, V7 p( T& |$ Ngetchar();( b1 [% Y" Z+ j5 T9 b! C, Q- O
return 0;9 \% m6 F0 `+ r8 G1 {- }* E
2 y) o! ]" \! C8 `) t o
}6 w+ f; t; V; o/ N2 _
^) T+ A* m2 S运行效果如下图:. u$ F* w: f3 h+ i! j# g/ u- B
$ ? Q" O5 o0 N5 U+ t H f
0 k8 }* F3 ^2 T5 c$ z4 G F
释放前后,内存并没有太大变化。我感到很困惑,这是什么原因呢? |
|