halting problem :)

BCS ao at pathlink.com
Tue Jan 27 10:10:58 PST 2009


Reply to Saaa,

> My program doesn't exit..
> 
> void main()
> {
> ..
> Data data[]
> createData(data);
> //This proces takes a minute or two.
> //data now holds about 700000 Data elements
> writefln(`Creating buffer`);
> ubyte[] buffer;
> for (int i=0; i<data.length; i++)
> {
> 
> buffer~=format(data[i].net,`,`,data[i].name,`,`,to!(int[])(data[i].out
> put),`,`,to!(int[])(data[i].input),newline);

~= in a short loop is a really bad thing. It will tend to need twice the 
ram you really needed and hammers the GC. Also if you start getting false 
pointers it gives them lots of memory segments to land in.

> //This takes like a minute and has a peak memory usage of 680MB
> }
> writefln(`Writing file`);
> std.file.write(outFilename, buffer);
> writefln(`Writing file finished`);
> //The file is readily made and delta memory usage shows a few a few
> times
> around 20MB
> //but the program doesn't stop, although 'Writing file finished' is
> shown.
> //there is no static this or alike.
> //and after 10 minutes the memory usage is about 370MB and slowly
> going up
> //ctrl-c doesn't work anymore as well
> }




More information about the Digitalmars-d-learn mailing list