digitalmars.D.learn - Set array size to simplify mem mgmt
- Ald (5/5) Jul 05 2007 Hello.
- Oskar Linde (5/13) Jul 05 2007 That is equivalent to reserving 256 chars. Enlarging the unitStack will
- Ald (2/17) Jul 05 2007 What sort of guarantee there is that the memory manager will not give th...
- Oskar Linde (6/25) Jul 05 2007 The 256 bytes form a continuous chunk. As long as any reference
Hello. I have the following code: char[] unitStack = new char[256]; unitStack.length = 0; Does it make sense from viewpoint of simplifying memory management? If I enlarge the size, the array won't be reallocated?
Jul 05 2007
Ald skrev:Hello. I have the following code: char[] unitStack = new char[256]; unitStack.length = 0; Does it make sense from viewpoint of simplifying memory management? If I enlarge the size, the array won't be reallocated?That is equivalent to reserving 256 chars. Enlarging the unitStack will not cause reallocation for at least the first 256 entries. -- Oskar
Jul 05 2007
Oskar Linde Wrote:Ald skrev:What sort of guarantee there is that the memory manager will not give the 127th through 255th chars to somebody else?Hello. I have the following code: char[] unitStack = new char[256]; unitStack.length = 0; Does it make sense from viewpoint of simplifying memory management? If I enlarge the size, the array won't be reallocated?That is equivalent to reserving 256 chars. Enlarging the unitStack will not cause reallocation for at least the first 256 entries. -- Oskar
Jul 05 2007
Ald skrev:Oskar Linde Wrote:The 256 bytes form a continuous chunk. As long as any reference (pointer) to any element within that chunk exists, the GC will not reclaim any part. unitStack.length = 0; will not change unitStack.ptr. -- OskarAld skrev:What sort of guarantee there is that the memory manager will not give the 127th through 255th chars to somebody else?Hello. I have the following code: char[] unitStack = new char[256]; unitStack.length = 0; Does it make sense from viewpoint of simplifying memory management? If I enlarge the size, the array won't be reallocated?That is equivalent to reserving 256 chars. Enlarging the unitStack will not cause reallocation for at least the first 256 entries. -- Oskar
Jul 05 2007