Memory allocation faile on string concat
Steven Schveighoffer
schveiguy at yahoo.com
Wed Nov 10 11:06:40 PST 2010
On Wed, 10 Nov 2010 13:55:26 -0500, sybrandy <sybrandy at gmail.com> wrote:
> On 11/10/2010 11:33 AM, Xie wrote:
>> Can't run a simple program. What's wrong, GC?
>>
>> import std.stdio;
>> import std.date;
>>
>> void f0()
>> {
>> wstring a[];
>>
>> foreach(i; 0 .. 100_000_000)
>> {
>> a ~= " "w;
>> }
>> }
>>
>> void main()
>> {
>> auto r = benchmark!(f0)(1);
>> writeln(r, "ms");
>> }
>>
>> DMD 2.047
>
> In addition to what everybody else is suggesting you look at, you may
> want to look into using an appender (defined in std.array). Not sure if
> it will help with the memory usage, but it's supposed to be faster for
> appending data to an array.
Just tried it, Appender is actually slower. This *is* a problem, it
should be way faster than builtin array appending.
I will look into it.
-Steve
More information about the Digitalmars-d-learn
mailing list