QImage out of memory and OpenMP conflict



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


  • Lifetime Qt Champion

    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)




  • Lifetime Qt Champion

    Interesting... Thanks for sharing !



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


Log in to reply
 

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