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 7530763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:59:59+00:00 2026-05-30T04:59:59+00:00

I have a problem with IplImage* returned from cvQueryFrame … Its memory is never

  • 0

I have a problem with IplImage* returned from cvQueryFrame… Its memory is never released by library. And documentation says:

The returned image should not be released or modified by the user.

Well… how do I get my memory back? The program eats memory until it crashes. I would like to release allocated memory for each IplImage* after frame processing finishes. Code is this:

// In `process` thread:
CvCapture* camera;
camera = cvCreateCameraCapture(1);
assert(camera);
while(true)
{
    main = cvQueryFrame(camera);
    // Do something useful with images 
    emit sendImage(main); // Send Image to the UI thread
}

UPDATE:
This is QThread subclass:

#include <QThread>
class ImageFetcher : public QThread
{
    Q_OBJECT
public:
    explicit ImageFetcher(QObject *parent = 0);
signals:
    void run();
public slots:
};

Implementattion:

void ImageFetcher::run()
{
    CvCapture* camera = cvCreateCameraCapture(0);
    IplImage* image;
    while(true)
    {
        image = cvQueryFrame(camera);
        // process image
    }
    // exec();
}

main():

int main(int argc, char *argv[])
{
    QApplication a(argc,argv);
    ImageFetcher thread;
    thread.start();
    return a.exec();
}
  • 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-30T05:00:00+00:00Added an answer on May 30, 2026 at 5:00 am

    As far as I could test, there’s no leak in v2.3.1 for Linux.

    Here is what happens: an image is allocated by cvQueryFrame() when this function is called by the first time, and then this image is reused on all subsequent calls to cvQueryFrame(). No new images are created after the first call, and the image is only freed at cvReleaseCapture().

    So you see, if you are experiencing a memory leak (how did you find it, exactly?) and a crash, it is most probably caused by some other part of your code. If sendImage() is not synchronized (i.e. non-blocking) passing main image directly could cause problems. I don’t know what you are doing in this function, so I’ll assume the problem is inside it.

    One test you could do, is copy the main frame and then pass that copy to sendImage() instead, then release it when you no longer need it.

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

Sidebar

Related Questions

I have an problem freeing up memory allocated for an IplImage .I have given
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have problem while sending messages from android to PC. Messages are send when
Have problem while getting data from Memcached on .NET MVC solution. I have this
I have problem with displaying bitmap image on imageview on high density screen (480x800).
i have problem passing data from one page to another using GET, for example
I have problem when creating a file in encoding 'utf-8' and reading it from
I have a 3-channel IplImage. I would like to create a 4-channel image and
I have problem with $_POST data. Some fields are missing from input form when
I have problem I have never met before. I was clearing yesterday clients db

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.