www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13558] New: GC.free does not work for array pointers of

https://issues.dlang.org/show_bug.cgi?id=13558

          Issue ID: 13558
           Summary: GC.free does not work for array pointers of larger
                    size
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: public dicebot.lv

Original NG topic :
http://forum.dlang.org/post/uankmwjejsitmlmrbufe forum.dlang.org

This code does not actually free anything:

```
void main()
{
    ubyte[] result;
    result.length = 4096;
    GC.free(result.ptr);
}
```

This happens because for larger size blocks capacity is stored in the beginning
of the memory block making actual `array.ptr` interior pointer. Interior
pointers are ignored by GC.free

There are several possible ways for fixing this that are being considered right
now.

--
Sep 30 2014