Ada : read > 8 M from file = Memory fault
Hi,
I am trying to find a way to read large size blocks from a text file in Ada. Whatever I try, however, I get memory faults when trying to read more than 8.5 M. Anyone an idea how I should really do this ? This programme: memory fault Code:
with ada.streams.stream_io ;use ada.streams.stream_io; Code:
with ada.text_io; use ada.text_io; |
I guess the string is being allocated on the stack so the segfault is caused by stack overflow. You'll need to allocate the memory from the heap; I gather from this page that ada calls this "pool access".
|
Thank you
I made the streams version work by using a pointer. Unfortunately streams turn out to be extremely slow, I had not thought of that. A small check with a 4 M buffer with direct_io shows that direct_io does have an acceptable speed. I have not found a solution for that package however, because it needs a type as an argument. But for the streams variant, this works: Code:
with ada.streams.stream_io ;use ada.streams.stream_io; |
solution
well I found it
the code should be Code:
with ada.text_io, Interfaces.C_Streams; The above is just as fast as the c++code below. My input files are utf-8, but the seperator tokens are all ascii, so this does not pose a problem. My guess is that gcc compiles it to about the same thing as Code:
#include <iostream> |
All times are GMT -5. The time now is 06:29 PM. |