Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7169417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:59:07+00:00 2026-05-28T14:59:07+00:00

I already some post about releasing all the IplImage and all the CvMat structure

  • 0

I already some post about releasing all the IplImage and all the CvMat structure and CvMemStorage, but still I have some memory problems.

Do I have to release also CvPoint, CvScalar, CvPoint* (array of 3 CvPoints, do i have to free each element too?)

If I have to release all this stuff, how do I? I did not find any function to do so. I’m using OpenCV 2.1 in C/C++.

Here is how I declare them:

CvScalar b1;
CvScalar f;
float *data=(float*)resd->imageData; (need to release data)
CvPoint *point;
CvPoint pt;
CvPoint* ptsCorner=(CvPoint*) malloc(3*sizeof(ptsCorner[0]));   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:59:08+00:00Added an answer on May 28, 2026 at 2:59 pm

    This question is much more C related than OpenCV. For instance, these:

    CvScalar b1;
    CvScalar f;
    CvPoint pt;
    

    are local variables, and therefore they are automatically dealocatted when the scope { } they belong finishes executing.

    This:

    CvPoint *point;
    

    is a pointer, and at the same time is a local variable. You shouldn’t delete or free() it because you didn’t allocated any memory for it through new or malloc(). Doing so will cause you problems (probably a crash).

    But data on the other hand:

    float *data = (float*)resd->imageData;
    

    is a pointer and local variable that holds a memory block. However, it’s not wise to delete[] data; or free(data) in this specific case because you didn’t allocate this memory directly. It’s obvious that this memory was allocated as a part of resd, which means you have to check the code and find out how the variable resd was declared/initialized and then do the appropriate procedure to release it. Since I know a litle bit about OpenCV I can tell that resd is an IplImage*. If you used cvCreateImage() to create this variable then is also your job to release it with cvReleaseImage().

    At last:

    CvPoint* ptsCorner=(CvPoint*) malloc(3*sizeof(ptsCorner[0]));  
    

    It’s the tipical case of dynamic memory allocation, where you specifically allocate an amount of memory. Since ptsCorner is a local variable and a pointer, when the scope it belongs to finishes executing you will loose the reference to that memory block and it will simply be lost in your RAM, caonsuming memory space and causing a leak. It’s needless to say that you must execute free() to deallocate the memory in this case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have already seen a post about the error but This is some what
I already seen some question from here (stackoverflow) and THIS post, but I still
I have already read some info about his issue on the web, but I
I know there are already some posts about this topic, but I cannot find
I have found already some similar discussion on this, but would like to investigate
I have already read some posts, but no one helped me with my problem.
I have already post a question about start a broadcast on button click so
Hii, there are many others had already post so many question about this..But here
I have a table named Annonce that contains some informations about a post ;
I have already some applets ready. I tried to run it on android tablet.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.