Re: GC doesn't collect where expected

2023-06-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/19/23 2:01 PM, axricard wrote: Does it mean that if my function _func()_ is as following (say I don't use clobber), I could keep a lot of memory for a very long time (until the stack is fully erased by other function calls) ? ``` void func() {    Foo[2048] x;    foreach(i; 0 ..

Re: GC doesn't collect where expected

2023-06-19 Thread axricard via Digitalmars-d-learn
On Monday, 19 June 2023 at 16:43:30 UTC, Steven Schveighoffer wrote: In general, the language does not guarantee when the GC will collect your item. In this specific case, most likely it's a stale register or stack reference. One way I usually use to ensure such things is to call a

Re: GC doesn't collect where expected

2023-06-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/19/23 12:51 PM, Anonymouse wrote: On Monday, 19 June 2023 at 16:43:30 UTC, Steven Schveighoffer wrote: In this specific case, most likely it's a stale register or stack reference. One way I usually use to ensure such things is to call a function that destroys the existing stack: ```d

Re: GC doesn't collect where expected

2023-06-19 Thread axricard via Digitalmars-d-learn
On Monday, 19 June 2023 at 16:43:30 UTC, Steven Schveighoffer wrote: In general, the language does not guarantee when the GC will collect your item. In this specific case, most likely it's a stale register or stack reference. One way I usually use to ensure such things is to call a function

Re: GC doesn't collect where expected

2023-06-19 Thread Anonymouse via Digitalmars-d-learn
On Monday, 19 June 2023 at 16:43:30 UTC, Steven Schveighoffer wrote: In this specific case, most likely it's a stale register or stack reference. One way I usually use to ensure such things is to call a function that destroys the existing stack: ```d void clobber() { int[2048] x; } ```

Re: GC doesn't collect where expected

2023-06-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/19/23 12:13 PM, axricard wrote: I'm doing some experiments with ldc2 GC, by instrumenting it and printing basic information (what is allocated and freed) My first tests are made on this sample : ``` cat test2.d import core.memory; class Bar { int bar; } class Foo {   this()   {   

GC doesn't collect where expected

2023-06-19 Thread axricard via Digitalmars-d-learn
I'm doing some experiments with ldc2 GC, by instrumenting it and printing basic information (what is allocated and freed) My first tests are made on this sample : ``` cat test2.d import core.memory; class Bar { int bar; } class Foo { this() { this.bar = new Bar; } Bar bar; }