static void arrays under garbage control?

2015-02-25 Thread captaindet via Digitalmars-d-learn
if i understand correctly, static arrays are exempt from GC scanning for memory pointers http://dlang.org/garbage.html : "Pointers in D can be broadly divided into two categories: Those that point to garbage collected memory, and those that do not. Examples of the latter are pointers created by

Re: static void arrays under garbage control?

2015-02-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 26 February 2015 at 01:15:37 UTC, captaindet wrote: pointers to static data." Keep in mind that this is pointers TO static data - that is, if the object itself is static, it is not to be collected. static int[5] foo = [1,2,3,4,5]; // foo will never be collected, even if there a

Re: static void arrays under garbage control?

2015-02-25 Thread captaindet via Digitalmars-d-learn
On 2015-02-25 19:24, Adam D. Ruppe wrote: does this warning only apply to dynamic void[] arrays but not to static void[CTconstant] arrays? Both of those will be scanned for pointers. thanks, adam, so i should always use struct Stuff2Do{ static ubyte[1024*1024] buffer4speed = void; // e

Re: static void arrays under garbage control?

2015-02-25 Thread Adam D. Ruppe via Digitalmars-d-learn
You don't have to do all that, if it is typed ubyte[] instead of void[], it shouldn't be scanned at all anyway.

Re: static void arrays under garbage control?

2015-02-25 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Feb 25, 2015 at 08:20:37PM -0600, captaindet via Digitalmars-d-learn wrote: [...] > struct Stuff2Do{ > static ubyte[1024*1024] buffer4speed = void; // even if untyped at this > point > > // more > } [...] Tangential note: be careful with putting a large static array inside a str

Re: static void arrays under garbage control?

2015-02-25 Thread ketmar via Digitalmars-d-learn
On Wed, 25 Feb 2015 20:20:37 -0600, captaindet wrote: > On 2015-02-25 19:24, Adam D. Ruppe wrote: >>> does this warning only apply to dynamic void[] arrays but not to >>> static void[CTconstant] arrays? >> >> Both of those will be scanned for pointers. > > thanks, adam, > > so i should always us

Re: static void arrays under garbage control?

2015-02-25 Thread captaindet via Digitalmars-d-learn
On 2015-02-25 20:45, H. S. Teoh via Digitalmars-d-learn wrote: On Wed, Feb 25, 2015 at 08:20:37PM -0600, captaindet via Digitalmars-d-learn wrote: [...] struct Stuff2Do{ static ubyte[1024*1024] buffer4speed = void; // even if untyped at this point // more } [...] Tangential note:

Re: static void arrays under garbage control?

2015-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/25/15 8:15 PM, captaindet wrote: if i understand correctly, static arrays are exempt from GC scanning for memory pointers http://dlang.org/garbage.html : "Pointers in D can be broadly divided into two categories: Those that point to garbage collected memory, and those that do not. Examples

Re: static void arrays under garbage control?

2015-02-26 Thread captaindet via Digitalmars-d-learn
On 2015-02-26 10:07, Steven Schveighoffer wrote: Static data I believe is always scanned conservatively because no type information is stored for it ever, even on allocation (i.e. program startup). ouh, the confusion goes on... are you saying that { // will be all scanned by GC for /

Re: static void arrays under garbage control?

2015-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/26/15 11:57 AM, captaindet wrote: On 2015-02-26 10:07, Steven Schveighoffer wrote: Static data I believe is always scanned conservatively because no type information is stored for it ever, even on allocation (i.e. program startup). ouh, the confusion goes on... are you saying that {

Re: static void arrays under garbage control?

2015-02-26 Thread captaindet via Digitalmars-d-learn
On 2015-02-26 12:07, Steven Schveighoffer wrote: On 2/26/15 11:57 AM, captaindet wrote: On 2015-02-26 10:07, Steven Schveighoffer wrote: Static data I believe is always scanned conservatively because no type information is stored for it ever, even on allocation (i.e. program startup). ouh, th

Re: static void arrays under garbage control?

2015-02-26 Thread Ali Çehreli via Digitalmars-d-learn
On 02/26/2015 10:07 AM, Steven Schveighoffer wrote: >> // will not be scanned by GC for pointers: >> void[] buffer4 = cast(void[])(new ubyte[16]); >> uint[] buffer5 = cast(uint[])(new ubyte[16]); > > Correct, since they are allocated as ubyte[]. uint[] also would not be > scanned.

Re: static void arrays under garbage control?

2015-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/26/15 2:28 PM, Ali Çehreli wrote: On 02/26/2015 10:07 AM, Steven Schveighoffer wrote: >> // will not be scanned by GC for pointers: >> void[] buffer4 = cast(void[])(new ubyte[16]); >> uint[] buffer5 = cast(uint[])(new ubyte[16]); > > Correct, since they are allocated as