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 and OpenMP conflict
Qt 6.11 is out! See what's new in the release blog

QImage out of memory and OpenMP conflict

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.2k Views 1 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.
  • J Offline
    J Offline
    JulienMaille
    wrote on last edited by
    #1

    Dear all,
    I have a program that handles live image processing and display.
    A few days ago, I started getting random error messages saying:
    [quote]QImage: out of memory, returning null image[/quote]When checking the memory consumption, I saw nothing alarming, around 120M for my application and this number is stable over a few hours.

    After hours chasing that bug, I finally narrowed it down to a part of the code that perform a flip of the image. If I comment out the openMP macro, it works fine. If I keep it, then I have random crashes after a couple of hours.
    @if( softFlipX )
    {
    #pragma omp parallel for
    for( int y=0; y<_imgH; ++y ) // _imgH,_imgW ~= 512
    {
    for( int x=0; x<_imgW/2; ++x )
    {
    int temp = buf[x+y*_imgW];
    buf[x+y*_imgW]=buf[_imgW-1-x+y*_imgW];
    buf[_imgW-1-x+y*_imgW]=temp;
    }
    }
    }@
    So I'm wondering: what can trigger the "out of memory" message, and how does it conflict with the part of the code that uses openMP?
    Thanks a lot for your help!

    EDIT:
    the problem occurs in
    @QImage QImage::convertToFormat(Format format, Qt::ImageConversionFlags flags) const
    {
    if (!d || d->format == format)
    return *this;

    if (format == Format_Invalid || d->format == Format_Invalid)
        return QImage();
    
    const Image_Converter *converterPtr = &converter_map[d->format][format];
    Image_Converter converter = *converterPtr;
    if (converter) {
        QImage image(d->width, d->height, format);
    

    --> QIMAGE_SANITYCHECK_MEMORY(image);@
    d->width = d->height = 528
    format = RGB32
    and I have plenty of free memory.

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

      Hi,

      This question is a bit low-level, you should bring it to the interest mailing list, you'll find Qt's developers/maintainers there (this forum is more user oriented)

      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
      0
      • J Offline
        J Offline
        JulienMaille
        wrote on last edited by
        #3

        Finally found it:
        http://connect.microsoft.com/VisualStudio/feedback/details/340292/openmp-leaks-thread-handels-and-memory-when-used-in-threads

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

          Interesting... Thanks for sharing !

          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
          0
          • J Offline
            J Offline
            JulienMaille
            wrote on last edited by
            #5

            And the workaround for msvc:
            @ omp_set_dynamic(1);@

            1 Reply Last reply
            0

            • Login

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