Bug 7271 – Calling struct.init causes a memory allocation.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2012-01-11T09:03:00Z
Last change time
2012-07-04T11:04:10Z
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2012-01-11T09:03:33Z
struct MemoryBlockInfo
{
size_t size;
long[10] backtrace;
int backtraceSize;
this(size_t size)
{
this.size = size;
}
}
int main(string[] argv)
{
MemoryBlockInfo info;
info = MemoryBlockInfo.init; //array allocation here
}
This allocation seems totaly unneccesary. Also TypeInfo.init should return a immutable(void)[] instead of a void[] as it seems totaly illogical to modify the data retreived by TypeInfo.init.
This is especially critical when working without a GC because one is not able to free the allocated memory for the array as the allocation gets generated by the compiler.
Comment #2 by bearophile_hugs — 2012-07-04T11:04:10Z
(In reply to comment #1)
> Discussion suggesting this is resolved and should be closed.
Now it's closed as fixed.
> I couldn't find the issue it was a duplicate of.
Maybe it was fixed fixing Issue 7243