Why are commands executing out of order?
Josh
moonburntm at gmail.com
Sat Feb 2 07:22:50 PST 2013
On Saturday, 2 February 2013 at 11:16:50 UTC, FG wrote:
> On 2013-02-02 07:49, Josh wrote:
>> But main's first writeln actually outputs after f.close().
>
> Maybe because of output buffering and you need to add flush?
How do I do that? I've never heard of flush before.
>> The program uses ~1GB of RAM overall, even though main.results
>> is ~50MB
>> according to memSize.
>
> Wrong comparison. You should have compared to the output file's
> size.
> info.sizeof doesn't include the size of info.name.
> In my test results were 30 MB but the output file was 101 MB.
Yeah, my output file was 126MB. I figured strings had a set
amount of memory they could use, like an int can use exactly 4
bytes.
> But if you really have to do some extra processing of results,
> then you can reduce the memory used like 6 times by using an
> Appender instead of concatenating arrays and by reserving a
> reasonable number of records, to limit possible initial
> fragmentation when the array is resized. My program used 145 MB
> whereas the output file was 101 MB. I think it's good enough.
I've never come across Appenders before. Could you please explain
them a little bit, and what each call in your modified code does?
Thanks,
Josh
More information about the Digitalmars-d-learn
mailing list