Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QImage: out of memory, returning null image,How slove the this problem?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 6.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hurely
    wrote on last edited by
    #1

    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.

    jsulmJ 1 Reply Last reply
    1
    • H hurely

      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.

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @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)?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      H 1 Reply Last reply
      1
      • H Offline
        H Offline
        hurely
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • jsulmJ jsulm

          @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)?

          H Offline
          H Offline
          hurely
          wrote on last edited by
          #4

          @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.

          jsulmJ 1 Reply Last reply
          0
          • H hurely

            @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.

            jsulmJ Online
            jsulmJ Online
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @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.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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 ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              H 1 Reply Last reply
              0
              • SGaistS SGaist

                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 ?
                H Offline
                H Offline
                hurely
                wrote on last edited by
                #7

                @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?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

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

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  2

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved