Either I'm confused or the gc is

Steven Schveighoffer schveiguy at gmail.com
Sat Oct 24 15:49:22 UTC 2020


On 10/24/20 11:04 AM, Steven Schveighoffer wrote:
> On 10/24/20 10:21 AM, donallen wrote:
>> This does not panic! In theory, this should consume the same amount of 
>> GC memory as the format call (though I have not looked at the format 
>> code; there may well
>> be intermediate allocations as it does its work).
> 
> Just for informational purposes, an append statement between N strings 
> allocates one block that holds all of them. Format appends, so it may 
> involve multiple allocations, though it's possible it does a similar 
> shortcut. I'm very interested in this code, I will look at the case for 
> format, and see if I can sleuth out any possible corruption possibilities.

Can you try this? This will remove format from the picture, but still 
use appender in the same way format does (to focus on whether the 
problem is in std.format or appender):

// instead of this
// children[i].path = format("%s:%s", account.path, children[i].name);

{ // need a scope to ensure appender goes out of scope
    import std.array;
    appender!string app;
    app.put(account.path);
    app.put(":");
    app.put(children[i].name);
    children[i].path = app[];
}

If this still panics, then I can eliminate all of std.format. If it 
doesn't panic, then it's most likely in std.format.

A closer look at appender, and it seems all correct. I'm kinda hoping 
this doesn't panic, but at the same time, the appender code is a lot 
less complex, so easier to examine closely.

-Steve


More information about the Digitalmars-d mailing list