AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2012.09.06 15:30 "[Tiff] Managing the buffer", by
2012.09.06 17:10 "Re: [Tiff] Managing the buffer", by
2012.09.07 09:21 "Re: [Tiff] Managing the buffer", by
2012.09.07 09:57 "Re: [Tiff] Managing the buffer", by Joris Van Damme
2012.09.07 10:26 "RE: [Tiff] Managing the buffer", by
2012.09.07 11:01 "Re: [Tiff] Managing the buffer", by Joris Van Damme
2012.09.07 13:12 "RE: [Tiff] Managing the buffer", by
2012.09.07 13:39 "Re: [Tiff] Managing the buffer", by Joris Van Damme
2012.09.07 13:45 "RE: [Tiff] Managing the buffer", by
2012.09.07 14:16 "Re: [Tiff] Managing the buffer", by Bob Friesenhahn
2012.09.07 14:31 "Re: [Tiff] Managing the buffer", by
2012.09.07 15:52 "Re: [Tiff] Managing the buffer", by Bob Friesenhahn
2012.09.07 11:25 "Re: [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/