2012.09.06 15:30 "[Tiff] Managing the buffer", by

2012.09.07 09:57 "Re: [Tiff] Managing the buffer", by Joris Van Damme

Robert,

> ...sometimes it happens that at one moment when TIFFOpen is called, there isn't enough available memory for the buffer... Pre-allocating... seems like the solution

In this situation, any allocation in LibTiff may result in trouble, and there's probably plenty. I'd look into redirecting the LibTiff allocation routine, making it grab memory from a pre-allocated pool of yours. Seeing all your images are similar size and similarly handed off to LibTiff, you could easilly determine some upper bound to the total required memory by LibTiff in this situation, once you succeed in plugging into LibTiff's memory allocation and release routines. Add 25% for safety, set aside a pool this size at start-up, have LibTiff eat from this pool, make double sure to reset all your pool management stuff after TIFFClose so as to protect against leaks, and you can't fail on any LibTiff allocation any more.

See also http://www.remotesensing.org/libtiff/man/TIFFmemory.3tiff.html

Joris Van Damme
AWare Systems
info@awaresystems.be
http://www.awaresystems.be/