MantisBT - ITK | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0009320 | ITK | public | 2009-07-27 09:43 | 2010-10-21 12:31 | |
Reporter | Bradley Lowekamp | ||||
Assigned To | Bradley Lowekamp | ||||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | OS | OS Version | |||
Product Version | |||||
Target Version | Fixed in Version | ||||
Resolution Date | |||||
Sprint | |||||
Sprint Status | |||||
Summary | 0009320: MetaImageIO itkLargeImageWriterReadTests fails on apple, due to 2GB IO limitation | ||||
Description | On osx with even 64-bits builds, there is a limit to ~2GB for file reads and writes at once. Reads and writes in MetaIO should use a method which reads in smaller chunks. In the additional information section I have included code which could be used. The itkLargeImageWriteReadTests were added to test to see if itk::Image can deal with image greater then 2GB or 4GB. However, they fail on Mac OSX despite it being 64-bits with a 8-byte long. The apple OS is limited to only being able to read or write a maximum of 2GB at a time (regardless of 32 or 64-bit build). I don't know if this is the only OS with this limitation. The MetaIO library writes the files in one large block and therefore runs into this limitation. However the NRRD file format appears to read and write in smaller blocks, so by modifying the test to use NRRD it passes on my system. An alternative is to use streamed reading and writing (actually I am not sure if that would work to get around this for writing, as I think the ImageFileWriter writes the whole image if it is available even if it was requested to stream). | ||||
Steps To Reproduce | |||||
Additional Information | bool ReadBufferAsBinary( std::istream& is, void *buffer, StreamingImageIOBase::SizeType num ) { // some systems have a limit of 2GB to be read at once const SizeType maxChunk = 1024*1024*1024; std::streamsize bufferOffset = 0; std::streamsize bytesRemaining = static_cast<std::streamsize>( num ); while (bytesRemaining) { SizeType bytesToRead = bytesRemaining > maxChunk ? maxChunk : bytesRemaining; itkDebugMacro(<< "Reading " << bytesToRead << " of " << bytesRemaining << " bytes for " << m_FileName); is.read( static_cast<char *>( buffer ) + bufferOffset, bytesToRead ); if ( (is.gcount() != bytesToRead) || is.fail() ) { return false; } bufferOffset += bytesToRead; bytesRemaining -= bytesToRead; } return true; } bool WriteBufferAsBinary( std::ostream& os, const void *buffer, StreamingImageIOBase::SizeType num ) { // some systems have a limit of 2GB to be read at once const SizeType maxChunk = 1024*1024*1024; std::streamsize bufferOffset = 0; std::streamsize bytesRemaining = num; while (bytesRemaining) { SizeType bytesToWrite = bytesRemaining > maxChunk ? maxChunk : bytesRemaining; itkDebugMacro(<< "Writing " << bytesToWrite << " of " << bytesRemaining << " bytes for " << m_FileName); os.write(static_cast<const char*>(buffer)+bufferOffset , bytesToWrite); if ( os.fail() ) { return false; } bufferOffset += bytesToWrite; bytesRemaining -= bytesToWrite; } return true; } | ||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | bug9320.patch (10,534) 2009-11-12 11:37 https://public.kitware.com/Bug/file/2653/bug9320.patch bug9320-2.patch (690) 2009-11-16 11:24 https://public.kitware.com/Bug/file/2658/bug9320-2.patch | ||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2009-07-27 09:43 | Bradley Lowekamp | New Issue | |||
2009-09-08 12:01 | Bradley Lowekamp | Note Added: 0017330 | |||
2009-09-08 12:10 | Bradley Lowekamp | Note Added: 0017332 | |||
2009-09-08 12:50 | Sean McBride | Note Added: 0017333 | |||
2009-09-08 14:00 | Bradley Lowekamp | Note Added: 0017336 | |||
2009-09-08 14:34 | Bradley Lowekamp | Note Added: 0017340 | |||
2009-09-11 18:28 | Sean McBride | Note Added: 0017396 | |||
2009-11-02 16:18 | Bradley Lowekamp | Status | new => assigned | ||
2009-11-02 16:18 | Bradley Lowekamp | Assigned To | => Bradley Lowekamp | ||
2009-11-12 10:57 | Bradley Lowekamp | Note Added: 0018401 | |||
2009-11-12 11:37 | Bradley Lowekamp | File Added: bug9320.patch | |||
2009-11-12 11:54 | Julien Jomier | Note Added: 0018402 | |||
2009-11-16 11:24 | Bradley Lowekamp | File Added: bug9320-2.patch | |||
2009-11-16 11:26 | Bradley Lowekamp | Note Added: 0018443 | |||
2009-11-16 11:29 | Julien Jomier | Note Added: 0018444 | |||
2009-12-07 13:55 | Bradley Lowekamp | Note Added: 0018713 | |||
2009-12-07 13:55 | Bradley Lowekamp | Status | assigned => resolved | ||
2009-12-07 13:55 | Bradley Lowekamp | Resolution | open => fixed | ||
2010-10-21 12:31 | Gabe Hart | Status | resolved => closed |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|