OpenCV中文网站

 找回密码
 立即注册
搜索
热搜: 安装 配置
查看: 8291|回复: 2

vCreateFileCapture读取与释放产生内存泄漏的问题

[复制链接]
发表于 2012-7-14 22:53:37 | 显示全部楼层 |阅读模式
下面的函数是用来 显示一个视频内容的缩略图的函数,MFC写的。

现在发现一个很奇怪的问题。

现在情况是,一个列表控件里面有很多视频,当点击一个视频的时候,生成视频缩略图,内存平稳,没有泄漏。
当按着键盘的上下键来快速移动选择视频文件时候,内存就会暴增。达到几百兆轻而易举。
当选择一个视频文件的时候,产生一个线程,使用下面的函数处理。每次选择变化都会产生一个线程。

不知道内存暴增的原因是什么,有没有大大给解答下....       

  1. void CShowThumbnailPicThread::ShowVideo(CString strVideoPath, CStatic *imgCtrl, CRect rect)
  2. {
  3.         CvCapture *capture = NULL;
  4.         char *tmpPath = (CCommonFun::WcharToMultByte(strVideoPath.GetBuffer()));//这是个wchar_t转char的函数
  5.         capture = cvCreateFileCapture(tmpPath);
  6.         delete []tmpPath;
  7.         //定位到第200帧
  8.         cvSetCaptureProperty(capture, CV_CAP_PROP_POS_FRAMES, 200);
  9.         if (capture != NULL)
  10.         {
  11.                 if(!cvGrabFrame(capture))
  12.                 {
  13.                         cvReleaseCapture(&capture);
  14.                         ShowFileIcon(strVideoPath, imgCtrl, rect);//显示文件本身的图标函数
  15.                         return;
  16.                 }
  17.                 ////以下作为一个图像来处理//////////////////
  18.                 IplImage *img = NULL;
  19.                 img = cvRetrieveFrame(capture);
  20.                 if (img != NULL)
  21.                 {
  22.                         CRect rectTmp(rect);
  23.                         IplImage *imgTmp = ResizeImg(img, &rectTmp);        //缩放后的图像和显示的矩形区域
  24.                         if (imgTmp != NULL)        //如果缩放成功则显示
  25.                         {       
  26.                                 HDC hDC = imgCtrl->GetDC()->GetSafeHdc();
  27.                                 CvvImage CvvImage;
  28.                                 CvvImage.CopyOf(imgTmp);
  29.                                 imgCtrl->SetIcon(NULL);
  30.                                 CvvImage.DrawToHDC(hDC, &rectTmp);       
  31.                                 cvReleaseImage(&imgTmp);
  32.                                 ::ReleaseDC(AfxGetMainWnd()->m_hWnd, hDC);
  33.                         }
  34.                         else        //否则显示图像图标
  35.                                 ShowFileIcon(strVideoPath, imgCtrl, rect);//显示文件本身的图标函数
  36.                 }
  37.                 else
  38.                         ShowFileIcon(strVideoPath, imgCtrl, rect);
  39.                 //释放capture
  40.                 cvReleaseCapture(&capture);
  41.         }
  42.         else
  43.                 ShowFileIcon(strVideoPath, imgCtrl, rect);
  44.         return;
  45. }
复制代码
回复

使用道具 举报

 楼主| 发表于 2012-7-15 08:33:06 | 显示全部楼层

vCreateFileCapture读取与释放产生内存泄漏的问题

问题是就是多线程使用  cvCreateFileCapture 产生了大量内存泄漏。

把其他都注释掉,仅留下
  1. capture = cvCreateFileCapture(tmpPath);
  2. cvReleaseCapture(&capture);
复制代码
仍然如此。

有高人解答下吗?
回复 支持 反对

使用道具 举报

发表于 2012-9-11 14:57:45 | 显示全部楼层

vCreateFileCapture读取与释放产生内存泄漏的问题

Hublot - HBFC10003 Major Bang Black Ceramic [url=http://www.hoganbox.com/hogan-scarpe-leggere-donna-c-2.html:vyt5hbcu]Hogan Rebel[/url:vyt5hbcu] Frappagino A-7750
Hublot - HBFC10003 Massive Bang Black Ceramic Frappagino A-7750 $858.00
Frappagino Minimal Version Product : Entire Black Ceramic Situation, Black Ceramic Bezel, Brown Carbon Fibre dial, Brown Subdials, Elevate Silver Numeral Hour Markers on Rubber strap with Insignia Deployant Clasp Movement: Asian 7750 Valjoux Functioning Chronograph movement, 28800bph , Embellished Insignia Rotor Capabilities: Several hours, Minutes, Seconds : Jogging Secs at 9.00 subdials, Date : four.thirty Adjustment by means of Crown, Chronograph : 3.00 subdial - moment counter, six.00 subdials, hour counter two.00 pusher - start/stop chrono, 4.00 pusher - reset Dimensions : Dia forty four.5mm x 16mm Thk Content : 1 piece forged scenario construction, reliable 316 chrome steel, Complete Ceramic Again : Display situation back again with depth Engraved case rims Crown [url=http://www.hoganbox.com/:vyt5hbcu]scarpe hogan[/url:vyt5hbcu] : One-piece Screw down crown with o ring Crystal: - Sapphire crystal, Ambigu sided AR coated Water-resistant REMARKS : This range of Replicas may be the finest there is certainly ! All components completely interchangeable with the real enjoy.. absolutely free delivery

At [url=http://www.hoganbox.com/hogan-scarpe-uomo-2012-c-7.html:vyt5hbcu]hogan interactive 2012[/url:vyt5hbcu]  topareplica  , we concentrate on top quality replica watches.Swiss engineering,precision constructed timepieces.We are brands and sellers of these leading high quality replica watches,we will present you inexpensive rolex with manufacturing unit price as well as the highest quality items.Our duplicate rolex are usually not cheap imitations,they can be authentic replicas in the actual products and solutions.All our replica watches have alike feel and look with the first items.Sporting these expensive wanting reproduction watches is prestigious,they generate a statement at get the job done and at play.
Welcome to negotiate enterprise and set up long-term welcoming cooperation relationships with us during the around potential.
We expert investing company that focuses on top rated top quality clothing, jerseys,Sneakers,handbags, jewellery,Pen,sunglasses and swiss watches
Duplicate purses:
Gucci Handbags,Louis Vuitton Purse,Burberry Purses,Chanel Purses,Balenciaga Handbags,Barbarabui Purses,Chloe Handbags,Mentor Purses,Christian Dior Handbags,Hermes Handbags,Dolce & Gabbana Handbags,Prada Handbags,Jimmy Choo Handbags,Juicy Couture Purses,Fendi Handbags,Marc Jacobs Purses,Miu Miu Purses,Mulberry Handbags,Thomas Wylde Purses,YSL Purses,Givenchy Purses,Versace Handbags,Loewe Handbags,Valentino Purses,Mens Handbags,Wallet Handbags,BELT
Perfect swiss watches:
Rolex for Man Watches,Rolex for Lady Watches,Rolex Mid Size Watches,Officine Panerai Watches,Omega Watches,Hublot Watches,Anonimo Watches, A Lange & Sohne Watches,Alain Silberstein Watches,Audemars Piguet Watches,Baume & Mercier Watches,B.R.M Watches,Breitling Watches,Breguet Watches,Blancpain Watches,Bvlgari Watches,Burberry Watches,Bell Ross Watches,Bedat & CO Watches,Chaumet Watches,Carl F Bucherer Watches,Chronoswiss Watches,Cartier Watches,Corum Watches,Concord Watches,Christian Dior Watches,Chopard Watches,Chanel Watches,De Witt Watches,Ebel Watches,Equip Watches,Fendi Watches,Franck Muller Watches,Ferragamo Watches,Ferrari Watches,Glashutte Watches,Graham Watches,Gucci Watches,Hysek Watches,Hermes Watches,Harry Winston Watches,IWC Watches,Jaeger-LeCoultre Watches,Jacob & Co Watches,Longines Watches,Louis Vuitton Watches,Lamborghini Watches,Maurice LeCroix Watches,Mont Blanc Watches,Montega Watches,Movado Watches,MB&F Watches,Oakley Watches,Oris Watches,Porsche Design Watches,Prada Watches,Piaget Watches,Paul Picot Watches,Patek Philippe Watches,Pierre Kunz Watches,Parmigiani Fleurier Watches,Roger Dubuis Watches,Romain Jerome Watches,Richard Mille Watches,Sinn Watches,Tag Heuer Watches,Tudor Watches,Ulysse Nardin Watches,U-Boat Watches,Vacheron Constantin Watches,Versace Watches,Zenith Watches,$98 Japan Watches

Replica shoes :
FENDI Shoes,Bally Sneakers,Hogan Footwear,Coach Shoes,Burberry Sneakers,LV Footwear,Bottega Veneta Footwear,Chloe Sneakers,CHANEL Footwear,Christian Louboutin Sneakers,Versace Shoes,D&G Sneakers,Salvatore Ferragamo Sneakers,Gucci Footwear,JIMMY CHOO Sneakers,Prada Footwear,MARC JACOBS Footwear,Hermes Shoes,JC  Juicy Couture Footwear,YSL Footwear,TORY BURCH Sneakers,TODS Sneakers,Roger Vivier Shoes,Zegna Sneakers

Duplicate Clothes:
Marlboro Classics Clothes,FRED PERRY Clothes,TOMMY Clothes,Dior Clothes,Bikembergs Clothes,Versace Clothes,Paul Smith Clothes,Paul Shark Clothes,Childrens Clothes,Pierre Cardin Clothes,Ralph lauren Clothes,Lacoste Clothes,Louis Vuitton Clothes,Gucci Clothes,Armani Clothes,Hugo Boss Clothes,Burberry Clothes,Abercrombie & Fitch Clothes,D&G [url=http://www.hoganbox.com/:vyt5hbcu]scarpe hogan[/url:vyt5hbcu] Clothes,Ties Gift Set Clothes Scarf Clothes

Fashion Jewellery :
Bvlgari Jewelry,Cartier Jewellery,Gucci Jewellery,Tiffany & Co Jewelry,Juicy Jewellery
Fashion Pen :
Mont Blanc Pen,S T DUPONT Pen,Cartier Pen
We supply perfect replica luxury watches,
see mroe welcome to our web :
http:// topareplica
msn: replicatop@hotmail
Gmail: 002REPLICA@Gmail

Find Low cost replica watches of best quality
Read More Reviews on designer watches for Shopping Reference.
Find Everything about swiss watches,purses,sneakers



Related Articles - Hublot, Huge Bang Full Ceramic Series,
       
Email this Article to a Friend!
Receive Articles like this just one direct to your email box!Subscribe for no cost today!
http:// amazines /Online_Shopping/article_detail.cfm/2415790?articleid=2415790
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|OpenCV中文网站

GMT+8, 2024-5-6 16:16 , Processed in 0.009767 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表