It doesn't matter if cvReleaseImage is before cvWaitKey?
I change the order of cvReleaseImage and cvWaitKey, and it does work too.
#include "stdafx.h" int main(int argc, char** argv) { cvNamedWindow("testWindow",0); IplImage *img=cvLoadImage("E:/lena.jpg"); cvShowImage("testWindow",img); Sleep(10); cvReleaseImage(&img); cvWaitKey(0); cvDestroyWindow("testWindow"); return 0; }
Then I stepped into the program ,and cvReleaseImage did release the image, and Image Watch showed that img pointed to NULL,while when cvWaitKey was called, The img was shown on the window correctly!
To find the reason, I refered to the source code of cvShowImage:
CV_IMPL void cvShowImage( const char* name, const CvArr* arr ) { CV_FUNCNAME( "cvShowImage" ); __BEGIN__; CvWindow* window; SIZE size = { 0, 0 }; int channels = 0; void* dst_ptr = 0; const int channels0 = 3; int origin = 0; CvMat stub, dst, *image; bool changed_size = false; // philipg if( !name ) CV_ERROR( CV_StsNullPtr, "NULL name" ); window = icvFindWindowByName(name); if( !window || !arr ) EXIT; // keep silence here. if( CV_IS_IMAGE_HDR( arr )) origin = ((IplImage*)arr)->origin; CV_CALL( image = cvGetMat( arr, &stub )); if (window->image) // if there is something wrong with these system calls, we cannot display image... if (icvGetBitmapData( window, &size, &channels, &dst_ptr )) return; if( size.cx != image->width || size.cy != image->height || channels != channels0 ) { changed_size = true; uchar buffer[sizeof(BITMAPINFO) + 255*sizeof(RGBQUAD)]; BITMAPINFO* binfo = (BITMAPINFO*)buffer; DeleteObject( SelectObject( window->dc, window->image )); window->image = 0; size.cx = image->width; size.cy = image->height; channels = channels0; FillBitmapInfo( binfo, size.cx, size.cy, channels*8, 1 ); window->image = SelectObject( window->dc, CreateDIBSection(window->dc, binfo, DIB_RGB_COLORS, &dst_ptr, 0, 0)); } cvInitMatHeader( &dst, size.cy, size.cx, CV_8UC3, dst_ptr, (size.cx * channels + 3) & -4 ); cvConvertImage( image, &dst, origin == 0 ? CV_CVTIMG_FLIP : 0 ); // ony resize window if needed if (changed_size) icvUpdateWindowPos(window); InvalidateRect(window->hwnd, 0, 0); // philipg: this is not needed and just slows things down // UpdateWindow(window->hwnd); __END__; }
Note that window->image is linked with dst_ptr which is the MatHeader of dst, and dst is coverted by image. So ,we got that it is the coverted image "dst" rather than image itself shown on the window.
Another problem rises to my sight, when is dst released?
The only possible released time is cvDestroyWindow, while the source code doesn't show such a step.
So, there is a memory leak for cvShowImage, right?
Similarly, some other functions like cvCloneImage have the problem of memory leak
http://hi.baidu.com/gilbertjuly/item/aa13b19223a303b983d29550
Learning when and how to use release function is very important to avoid memory leak.
Basically, if we have applied for a memory using functions like cvLoadImage, cvCreatImage, it is required that a functional call of cvReleaseImage must be called. A special attention should be paid to cvRetrieveFrame , as the documentation says:
OpenCV 1.x functions cvRetrieveFrame and cv.RetrieveFrame return image stored inside the video capturing structure. It is not allowed to modify or release the image! You can copy the frame using cvCloneImage() and then do whatever you want with the copy.
(cvCopy may be better than cvCloneImage())
don't use cvReleaseImage to release the image each time you get a frame by cvRetrieveFrame.
Oct 17, 2019 03:05:50 AM
It's a nice post. I am happy to find it. Do you have anything else to show?
Apr 22, 2020 08:27:00 AM
Very nice blog as well as write-ups. I am truly very pleased to visit your blog site. Currently, I am discovered which I actually want. I check your blog every day and also attempt to learn something from your blog. Thanks and awaiting your brand-new blog post.
Apr 27, 2020 09:20:51 AM
First You got a fantastic blog site. I will want even more comparable topics. I see you obtained actually extremely beneficial subjects, I will be constantly examining your blog thanks. change wifi name and password
Apr 30, 2020 01:47:56 PM
I can not wait to dig kickoff and deep utilizing sources that I got from you. Your liveliness is refreshing. kbc winner
May 01, 2020 10:03:30 AM
Great Article it's ingenious and really helpful keep us uploaded with new updates. its was really useful.
thanks a great deal. imo lottery winner
May 02, 2020 01:51:05 AM
Hi there,
I found your website through Google while looking for an associated subject,
your internet site turned up, it looks fantastic.
I have bookmarked it in my google bookmarks. kbc head office number
May 06, 2020 09:43:41 PM
These specific papers remarkable,
and also My spouse and I take pleasure in each of the execute that you have actually put right into this.
I'm certain that you will certainly be making an actually useful place.
I have been in addition pleased. Excellent carry out! soft dog food for bad teeth
May 06, 2020 09:51:58 PM
Hi there,
I discovered your web site via Google while browsing for a relevant subject,
your site showed up, it looks great.
I have bookmarked it in my google book markings. assignment代写
May 07, 2020 07:04:42 PM
Wonderful task below on. I check out a great deal of post, but I never ever heard a topic such as this. I Love this subject you made regarding the blogger's pail list. Extremely resourceful. kbc head office number
May 07, 2020 07:36:19 PM
Amazing blog post. This isn't typically a hideous blog post and offers complete info. I such as to evaluate this blog post considering I met such a great deal of new genuine parts concerning it really. Thanks, loads. I bookmark your internet log in light of I discovered dumbfounding details on your weblog, Thanks for sharing. kbc winner
May 07, 2020 07:57:23 PM
Exceptional message.
Thanks to this blog site my expedition has finished. kbc lottery winner
May 07, 2020 08:49:29 PM
Due to the fact that of the offer it, this is a remarkable article I have actually seen. It is truly what I anticipated to see trust in the future you will continue in sharing such a mind-blowing blog post. kbc lottery
May 08, 2020 08:38:53 PM
It is really a well-researched web content as well as outstanding phrasing. I got so taken part in this material that I couldn't wait to read. I am amazed with your work as well as ability. Thanks. assignment代写
May 11, 2020 01:06:20 AM
Thanks for sharing wonderful information with us. I like your message and all you show to us depends on date as well as quite interesting, I would love to bookmark the page so I can come here once more to read you, as you have actually done a remarkable task. kbc
May 11, 2020 01:13:59 AM
Outstanding article. Many thanks to this blog site my expedition has ended. kbc live
May 11, 2020 01:21:41 AM
No question this is an outstanding blog post I got a great deal of understanding after checking out best of luck. The motif of the blog site is outstanding there is almost every little thing to check out, Brilliant blog post. kbc lottery winner
May 11, 2020 01:25:48 AM
Wonderful blog! I'm intending to start my very own site soon yet I'm a little lost on every little thing. Many thanks! kbc game
May 23, 2020 10:58:00 AM
Due to the fact that of the deal it, this is an amazing message I have actually seen. It is actually what I expected to see count on the future you will continue in sharing such a wonderful message. kbc lottery winner
May 23, 2020 11:01:10 AM
First You got a fantastic blog.
I will certainly have an interest in even more similar topics.
I see you got truly extremely helpful subjects,
i will be constantly examining your blog site many thanks. kbc official website
May 23, 2020 01:27:25 PM
These specific papers fantastic, and My partner as well as I delight in each of the carry out that you have positioned right into this. I'm sure that you will certainly be making a really useful location. I have actually been additionally pleased. Excellent do! kbc head office number
May 23, 2020 01:32:56 PM
I got so involved in this product that I couldn't wait to read.
Thanks. kbc head office number
May 23, 2020 01:37:12 PM
I can not wait to dig kickoff as well as deep making use of resources that I obtained from you.
Your vitality is refreshing. kbc head office number
May 24, 2020 07:04:29 PM
Since of the deal it, this is a wonderful blog post I have seen.
It is truly what I expected to see rely on the future you will proceed
in sharing such an astonishing message. best email marketing platforms
May 27, 2020 04:33:41 PM
I got so engaged in this product that I couldn't wait to review. Many thanks. jio lottery 2020
May 27, 2020 04:37:21 PM
I can not wait to dig deep and also kickoff utilizing resources that I received from you.
Your exuberance is refreshing. kbc winner 2020
Jun 04, 2020 11:31:14 AM
Positive site, where did u think of the info on this posting? I have reviewed a few of the posts on your website currently, and also I truly like your style. Thanks a million and also please maintain the reliable job. kbc winner list/a>
Jun 04, 2020 11:55:14 AM
Your work is absolutely appreciated round the globe and the clock. It is a incredibly thorough as well as valuable blog. kbc winner list
Jun 04, 2020 12:35:32 PM
I really enjoyed analysis this post, large follower. Maintain the great job and also please inform me when can you publish more articles or where can I learn more on the topic? kbc lottery winner
Jun 04, 2020 02:23:59 PM
Favorable site, where did u develop the details on this posting? I have read a few of the short articles on your web site currently, and I truly like your design. Thanks a million and please maintain the effective job. kbc contact number
Jun 04, 2020 02:29:11 PM
Extremely nice post, I took pleasure in reviewing your post, extremely nice share, I intend to twit this to my followers. Many thanks! kbc lottery winner
Jun 04, 2020 03:32:59 PM
First You got an excellent blog site. I will want more comparable topics. I see you obtained truly very beneficial subjects, i will be always examining your blog many thanks. kbc lottery
Jun 04, 2020 03:36:54 PM
Great Article it's actually helpful and also innovative keep us published with brand-new updates. its was truly beneficial. thanks a great deal. kbc winner 2021
Jun 04, 2020 03:40:24 PM
Thank you for this marvelous post, I rejoice I observed this web site on yahoo. jio lottery 2021
Jun 11, 2020 01:43:07 PM
Great blog post however I was wondering if you could compose a little bit much more on this topic? If you can clarify a little bit additional, I would certainly be extremely glad. Appreciate it! kbc lottery 2021
Jun 11, 2020 04:14:14 PM
Extremely good write-up, I enjoyed reading your article, very wonderful share, I wish to twit this to my followers. Thanks! kbc head office number
Jun 11, 2020 04:39:11 PM
You obtained a great blog. I will have an interest in even more comparable subjects. I see you got truly very valuable topics, i will be constantly examining your blog site thanks. jio lottery winner
Jun 11, 2020 04:59:49 PM
Great Article it's really useful and innovative maintain us uploaded with new updates. its was truly valuable. many thanks a lot. kbc lottery winner 2021
Jun 11, 2020 05:03:05 PM
Thanks for this fascinating post, I rejoice I observed this website on yahoo. kbc lucky draw 2021
Jun 11, 2020 06:29:49 PM
Fantastic blog site! Do you have any tips and tips for striving authors? I'm planning to start my very own web site soon yet I'm a little lost on everything. Would certainly you suggest beginning with a free system like WordPress or go for a paid alternative? There are so many choices available that I'm totally overwhelmed. Any type of recommendations? Numerous many thanks! kbc winner list
Jun 11, 2020 06:32:36 PM
Fabulous article, you have represented out some great points, I also assume this s an extremely fantastic website. I will see once again for more top quality web content and also, recommend this website to all. Thanks. kbc head office number
Jun 14, 2020 11:14:10 AM
Thank you for this remarkable post, I am thankful I observed this site on yahoo. להזמין נערת ליווי
Jun 23, 2020 10:38:11 AM
Excellent article however I was questioning if you could compose a little more on this subject? I 'd be very glad if you might elaborate a bit further. Value it! roku com link
Jul 05, 2020 11:34:36 PM
Think it or otherwise, it is the type of information I've long been attempting to discover. It matches my needs a great deal. Thanks for writing this details. ויאגרה גנרית
Jul 09, 2020 09:14:50 AM
Fabulous post, you have represented out some great points, I similarly think this s a very remarkable internet site. I will certainly visit again for even more quality material and also, advise this site to all. Many thanks. kbc lucky winner 2021
Jul 09, 2020 09:17:38 AM
Positive website, where did u create the info on this uploading? I have actually read a few of the posts on your website now, as well as I really like your style. Thanks a million and also please maintain the effective job. kbc lottery winner
Jul 10, 2020 08:56:34 AM
These particular papers remarkable, and My partner as well as I take pleasure in each of the carry out that you have put right into this. I'm certain that you will certainly be making a really helpful place. I have been furthermore delighted. Excellent carry out! kbc winner
Jul 10, 2020 09:00:16 AM
You actually make it look so very easy with your efficiency yet I discover this matter to be really something which I believe I would never understand. It seems too complex and extremely broad for me. I'm anticipating your next message, I'll attempt to master it! kbc number
Jul 14, 2020 11:40:36 AM
No question this is an outstanding blog post I obtained a great deal of knowledge after reading best of luck. The motif of the blog is outstanding there is almost every little thing to review, Brilliant blog post. how can i check my kbc lottery online?
Jul 15, 2020 08:56:38 AM
Truly pleased! Many thanks for sharing. kbc lottery check jio
Jul 15, 2020 09:42:51 AM
Exceptional site! I love just how it is simple on my eyes it is. I am examining how I could be notified whenever a brand-new article has been made. Looking for more brand-new updates. Have an excellent day! 网课代写
Jul 15, 2020 09:42:58 AM
Thanks for sharing wonderful info with us. I like your blog post and also all you show to us depends on day as well as quite useful, I wish to bookmark the page so I can come right here once more to read you, as you have actually done a fantastic task. paragonpoker
Jul 15, 2020 11:41:27 PM
Favorable website, where did u come up with the info on this posting? I have actually read a few of the posts on your internet site now, and I truly like your design. Many thanks a million and please maintain the effective work. kbc head office number
Jul 16, 2020 11:43:56 PM
I got way too much interesting things on your blog site. I think I am not the just one having all the pleasure here! Maintain up the excellent work. how to check kbc lottery winner 2021
Jul 18, 2020 09:54:59 AM
Excellent article yet I was questioning if you could create a little much more on this topic? If you can elaborate a little bit further, I would certainly be really grateful. Value it! Hppoker
Jul 18, 2020 09:57:46 AM
It is genuinely a well-researched material as well as superb phrasing. I obtained so involved in this product that I couldn't wait to read. I am satisfied with your work as well as ability. Thanks. mybestpoker
Jul 18, 2020 10:00:42 AM
I can not wait to dig deep as well as kickoff utilizing sources that I got from you. Your liveliness is rejuvenating. Lexispoker
Jul 20, 2020 10:54:01 AM
Think it or not, it is the kind of info I've long been looking for. It matches my needs a great deal. Thank you for composing this information. Judi Slot Online
Jul 25, 2020 09:21:38 AM
Hey, what a brilliant message I have actually stumbled upon and believed me I have been seeking for this comparable kind of post for past a week and also barely encountered this. Thanks significantly and also I will certainly seek even more posts from you. kbc lottery winner
Jul 25, 2020 09:26:08 AM
I obtained also much intriguing stuff on your blog site. I presume I am not the just one having all the pleasure here! Maintain up the excellent work. jio lottery winner list
Jul 25, 2020 09:26:15 AM
Fabulous post, you have actually denoted out some fantastic points, I likewise believe this s an extremely remarkable internet site. I will see once more for even more top quality web content as well as additionally, recommend this site to all. Thanks. dndpoker
Jul 26, 2020 09:46:40 AM
You really make it look so easy with your performance yet I find this issue to be in fact something which I believe I would never ever understand. It seems also challenging and also incredibly wide for me. I'm eagerly anticipating your following post, I'll attempt to master it! whatsapp lucky draw 2020 winner list
Jul 26, 2020 09:46:45 AM
Very wonderful post, I appreciated reading your message, really wonderful share, I wish to twit this to my followers. Thanks! whatsapp lottery 2020
Aug 08, 2020 03:08:44 AM
Actually pleased! Thanks for sharing. 먹튀검증사이트
Aug 08, 2020 03:09:08 AM
I desire you to say thanks to for your time of this terrific read!!! I certainly take pleasure in every little of it as well as I have you bookmarked to have a look at new stuff of your blog site a must-read blog! 먹튀커머스
Aug 11, 2020 09:13:04 PM
These certain papers amazing, as well as My spouse and also I take pleasure in each of the do that you have actually put into this. I'm certain that you will be making an actually useful location. I have been additionally pleased. Excellent carry out! แทงบอล
Sep 08, 2020 01:52:00 AM
Live vs . Patriots Live Stream . Steelers Live Stream . Broncos Live Stream . Cowboys Live Stream . Packers Live Stream .
Sep 10, 2020 02:49:44 AM
Hi there, I located your web site by means of Google while looking for an associated subject, your web site came up, it looks wonderful. I have actually bookmarked it in my google book markings. บุหรี่ไฟฟ้า
Sep 23, 2020 08:27:17 AM
Believe it or otherwise, it is the sort of details I've long been attempting to discover. It matches my needs a great deal. Thank you for composing this details. QR Code Generator
Oct 26, 2020 11:05:08 AM
Extremely nice blog site as well as write-ups. I am actually extremely happy to see your blog. Currently I am discovered which I in fact want. I examine your blog everyday and attempt to discover something from your blog. Thanks and also waiting on your brand-new article. radio app
Nov 09, 2020 03:13:59 AM
I review a whole lot of blog articles, however I never ever listened to a subject like this. I Love this subject you made regarding the blog writer's bucket checklist. 卡式台胞證
Nov 10, 2020 03:22:41 PM
These specific papers remarkable, as well as My spouse and also I appreciate each of the do that you have positioned right into this. I'm certain that you will be making a really helpful place. I have actually been in addition happy. Good do! 臺胞證
Nov 29, 2020 02:24:22 PM
norton.com/setup
norton.com/setup enter product key
norton.com/setup activate
Let's help you get the Norton
www.norton.com/setup or norton.com/setup
Form url www.norton.com/setup 2019 directly in the address bar of your browser.
Sign up for your Norton account.
Sign in or Build a new Norton Account
Then enter the key to your Norton product.
Choose to install Norton.
After the Norton Update has been completed, run the installation.
"You're all set up! The Norton is now mounted."
Significant points to be recalled when downloading Norton:
You will use your Norton account for all applications relevant to Norton.
If your product key has been redeemed and you are unable to find Norton apps. You can instal Norton directly on your Norton account.
Jan 18, 2021 11:02:20 AM
Excellent web site! I love how it is simple on my eyes it is. I am examining exactly how I could be alerted whenever a new post has been made. Looking for even more brand-new updates. Have a fantastic day! notes
Apr 08, 2021 06:28:06 PM
I inspect your blog every day as well as try to learn something from your blog site. Thank you and also waiting for your new post. framing a basement
May 08, 2021 07:15:10 AM
Extremely nice write-up, I enjoyed reviewing your article, really great share, I wish to twit this to my followers. Thanks! Relx
May 15, 2021 03:30:34 PM
These particular documents incredible, and My partner and I appreciate each of the carry out that you have positioned into this. I'm certain that you will certainly be making a truly useful location. I have actually been in addition happy. Excellent do! How Does Gmail Compare to Thexyz
May 20, 2021 08:30:02 AM
These certain papers wonderful, and My partner and also I delight in each of the carry out that you have put into this. I'm certain that you will be making a truly useful area. I have actually been additionally delighted. Great perform! Australian channel manager
May 21, 2021 04:45:08 PM
Thanks for your articles and your blog, I am wanting to start one myself for my own business - Its good checking out what other people write about and curious about where they get their ideas... My business is <a href="https://www.brisbanesouthwestfencing.com.au/">building Gates and Fencing</a> in Brisbane, QLD in Australia, not sure how I stumbled across your site from what I was searching for but I like to check out how different sites and blogs are structures and what people write about
May 21, 2021 04:46:11 PM
GRRR when I do that lol we do it when we dont use those little machines that do this for us hey oops.. I need to work out how to do that.
Jun 23, 2021 09:27:55 AM
Wonderful blog site! I'm intending to begin my own internet site soon however I'm a little lost on whatever. Many many thanks! eprimefeed.com Latest News Economy Politics Tech Sports Movies Fashion Life & Style الإخبارية
Aug 29, 2021 02:10:29 PM
Pretty good message. I just stumbled upon your weblog as well as wished to say that I have actually truly enjoyed searching your blog site messages. I'll be subscribing to your feed and also I hope you compose once more quickly! Togel Online24Jam Terpercaya 2020
Sep 26, 2021 07:28:23 PM
The next matter you can perform, to keep the house clean, is to keep an eye on every important item within your refrigerator. Don’t keep your expired foods in your own refrigerator. Expired foods can invoke ridiculous odours following getting fermented. This trick is really as beneficial because deep cleaning your home. Inspect your own refrigerator daily to discover such run out food as well as beverages within your fridge. Keep your leftovers within air-tight containers whenever you place them within your refrigerator.
Dec 07, 2021 12:08:27 PM
Very good short article, I delighted in reviewing your message, very great share, I intend to twit this to my fans. Thanks! joker123 online
Dec 13, 2021 10:40:14 AM
Fabulous blog post, you have denoted out some superb factors, I similarly assume this s an extremely remarkable website. I will certainly see again for more quality material as well as also, recommend this site to all. Thanks. Normanton Park
Jun 17, 2022 01:23:54 PM
This is an amazing post I have actually seen as a result of the deal it. It is actually what I expected to see count on in the future you will certainly continue in sharing such an astonishing post. resume builder