[Issue 1382] memory allocated for arrays in CTFE functions during compilation is not released

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 3 05:18:27 PDT 2009


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
                 CC|                            |clugdbug at yahoo.com.au

--- Comment #4 from Don <clugdbug at yahoo.com.au>  2009-08-03 05:18:25 PDT ---
I don't think Boehm gc is the answer. Note that this is very closely related to
bug#1330. I think the CTFE implementation of arrays needs (a) reference
semantics and (b) reference counting. Here's an example of a terrible case,
which allocates several Gb of RAM:

int junk(int n)
  int[] result = new int[10000];

  for(int i = 0; i < n; ++i) {
    result[0]= i;
  return 0;

const int bad = junk(100000);
void main() {}

This particular case could be solved by adding a reference-based system for
storing array values, instead of doing copy-on-write -- and that's required for
bug #1330 anyway.
Once that's in place, the array values could be allocated in a controlled
manner (eg, retain a list of all allocated CTFE arrays). A dedicated precise GC
can then be simple and fast, since it only needs to check for array references
in the current function, and they can only be in the local variables which are
arrays or structs.

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

More information about the Digitalmars-d-bugs mailing list