QImage: out of memory, returning null image,How slove the this problem?



  • When running the application,The Application Output often output the information about "QImage: out of memory, returning null image",BTW,the application could run successfully.The involved code like this :
    uchar *pBuffer = new uchar[size];//the size very large
    QImage dataImg(pBuffer, width, height, QImage::Format_RGB888);//one image size is about 110M
    emit sendImage(dataImg);
    //the above code in the standalone thread
    //receive the signal in the UI thread, when the error come out, I lost the Image.
    // Also, I try emit the pBuffer, construct the image in UI thread, but not helping, same problem.


  • Moderators

    @hurely Do you write anything into pBuffer?
    "the size very large" - how large?
    What are the values for width and height?
    Also do you free the memory at some point (pBuffer, QImage will not free it as described in the documentation)?



  • Thanks for reply!!!
    The size of image, about 110M. width:7376, height:4928.
    The pBuffer receive the RAW data from camera, so Image is large.
    I have already tried to free the memory after "emit sendImage(dataImg);",but UI show nothing, seem like that lost the image.



  • @jsulm Thanks for reply!!!
    The size of image, about 110M. width:7376, height:4928.
    The pBuffer receive the RAW data from camera, so Image is large.
    I have already tried to free the memory after "emit sendImage(dataImg);",but UI show nothing, seem like that lost the image.


  • Moderators

    @hurely You should not free the memory as long as the image is used as this buffer is used by QImage as stated in the documentation.


  • Lifetime Qt Champion

    Hi,

    In addition to what @jsulm wrote:

    • On what platform are you running your application on ?
    • What's the FPS ?
    • What are the specs of the device/machine you are running your application on ?


  • @SGaist Thanks for your reply!!!
    The Development Platform is PC windows 7 and running application on this platform.
    The FPS is about 5.
    I have already tested that showed one image on UI, the error didn't come out.
    I think the FPS is the key to this error, Is it too fast about emitting the QImage to UI thread?


  • Lifetime Qt Champion

    Well, it depends on several factors. What else does your application do ? What else consumes memory ? Are you running a 32bit application ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.