Using Multiple images (and threads)

Derek Magee D.R.Magee at leeds.ac.uk
Thu Jul 17 05:12:37 EDT 2014


Hi,

I have a (c++) app that uses openslide to open multiple (aperio svs) images in a multi threaded program. The thing is that if you open lots of images with openslide the memory usage becomes huge quite quickly. The solution I've been using is to close the images, however openslide_close as documented is not thread safe, so I wrap everything up with mutexes:

bool check_openslide()
{
    unsigned int timeout=0 ;
    while(m_dont_do_openslide_operation && timeout<100){
        Sleep(25) ;
        timeout++ ;
    } ;
    if(timeout==100) return false ;
    return true ;

}

// For thread safe functions (i.e. all but opeslide_close):

    if(!check_openslide()) return false ;
    m_doing_openslide_operation=true ;

// Some thread safe openslide operation

    m_doing_openslide_operation=false ;


// For openslide_close:

    if(!check_openslide()) return false ;
    m_dont_do_openslide_operation = true ;
    m_doing_openslide_operation=true ;

    openslide_close (meta->os_file_handle) ; // Close to save memory

    myclass->os_file_handle = openslide_open (myclass ->filename.c_str()) ; // Re-open as this only allocates a small memory footprint, and makes available for the future


    m_dont_do_openslide_operation = false ;
    m_doing_openslide_operation = false ;

So, I think the above should really be overkill mutex wise... but I still get a crash on openslide_close:

ERROR:src/openslide-decode-tiff.c:551:_openslide_tiffcache_destroy: assertion failed: (tc->outstanding == 0)

The scenario is I have ~1000 images and I'm getting a small tile from each in a multi-threaded program.

Any thoughts? Am I doing something wrong, or is there a multi-image bug somewhere?

Thanks

Derek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.andrew.cmu.edu/pipermail/openslide-users/attachments/20140717/99b09ee8/attachment.html 


More information about the openslide-users mailing list