On Sunday, 16 May 2021 at 11:42:19 UTC, Adam D. Ruppe wrote:
On Sunday, 16 May 2021 at 08:04:06 UTC, cc wrote:
[...]
destroy + GC.free has a quirk - GC.free only works on what
GC.malloc returns, a base pointer, NOT what `new` returns. The
documentation says this but it is a subtle detail eas
On Sunday, 16 May 2021 at 11:42:19 UTC, Adam D. Ruppe wrote:
On Sunday, 16 May 2021 at 08:04:06 UTC, cc wrote:
I tracked down the problem but wasn't 100% sure about the fix.
Adding the GC.baseOf thing works for me but i didn't upstream
since idk if it works for everyone else.
maybe i should
On Sunday, 16 May 2021 at 11:42:19 UTC, Adam D. Ruppe wrote:
On Sunday, 16 May 2021 at 08:04:06 UTC, cc wrote:
If the goal is to absolutely squeeze the GC back down after
using new or dynamic arrays, I find destroy + GC.free often
fails to do the trick (e.g. GC.stats.usedSize remains high).
d
On Sunday, 16 May 2021 at 08:04:06 UTC, cc wrote:
If the goal is to absolutely squeeze the GC back down after
using new or dynamic arrays, I find destroy + GC.free often
fails to do the trick (e.g. GC.stats.usedSize remains high).
destroy + GC.free has a quirk - GC.free only works on what
GC.
On Saturday, 15 May 2021 at 18:24:19 UTC, Alain De Vos wrote:
Thanks, good idea but,
It does not initiate a GC cycle or free any GC memory.
Personally I wish D would re-implement "delete" and make it "just
work" like one would assume, but from what I've seen there have
been many many debates
On Saturday, 15 May 2021 at 18:26:08 UTC, Adam D. Ruppe wrote:
On Saturday, 15 May 2021 at 17:55:17 UTC, Alain De Vos wrote:
Feature request, a function old which does the opposite of
new, allowing deterministic,real-time behavior and memory
conservation.
You're best off doing malloc+free if
I'll try first the first tip of Adam, here the code,
```
import std.stdio:writeln;
import core.memory: GC;
void myfun(){
class C{
int[1] x;
}//class C
struct S {
C c=null;
@disable this();
this(int dummy) {
c=new C();
On Saturday, 15 May 2021 at 17:55:17 UTC, Alain De Vos wrote:
Feature request, a function old which does the opposite of new,
allowing deterministic,real-time behavior and memory
conservation.
You're best off doing malloc+free if you want complete control
though.
Sorry free does , indeed.
On Saturday, 15 May 2021 at 18:15:24 UTC, Dennis wrote:
On Saturday, 15 May 2021 at 17:55:17 UTC, Alain De Vos wrote:
Feature request, a function old which does the opposite of
new, allowing deterministic,real-time behavior and memory
conservation.
You can use
[object.destroy](https://dlang.
Thanks, good idea but,
It does not initiate a GC cycle or free any GC memory.
On Saturday, 15 May 2021 at 17:55:17 UTC, Alain De Vos wrote:
Feature request, a function old which does the opposite of new,
allowing deterministic,real-time behavior and memory
conservation.
You can use
[object.destroy](https://dlang.org/phobos/object.html#.destroy)
to destruct, and
[GC.f
Feature request, a function old which does the opposite of new,
allowing deterministic,real-time behavior and memory conservation.
On Saturday, 15 May 2021 at 16:53:04 UTC, Adam D. Ruppe wrote:
On Saturday, 15 May 2021 at 16:52:10 UTC, Alain De Vos wrote:
When I do a "new" in a struct constructor to assign to a
member variable of this struct, what do i write in the same
struct destructor to free the memory ?
If you use
On Saturday, 15 May 2021 at 16:52:10 UTC, Alain De Vos wrote:
When I do a "new" in a struct constructor to assign to a member
variable of this struct, what do i write in the same struct
destructor to free the memory ?
If you used `new` the garbage collector is responsible for it.
On Saturday, March 2, 2019 4:32:53 AM MST JN via Digitalmars-d-learn wrote:
> Compare this D code:
>
> import std.stdio;
>
> struct Foo
> {
> ~this()
> {
> writeln("Destroying foo");
> }
> }
>
> void main()
> {
> Foo[string] foos;
>
> foos["bar"] = Foo();
> wr
On Saturday, 2 March 2019 at 11:32:53 UTC, JN wrote:
...
Is this proper behavior? I'd imagine that when doing
foos.remove("bar"), Foo goes out of scope and should be
immediately cleaned up rather than at the end of the scope? Or
am I misunderstanding how should RAII work?
https://dlang.org/s
On Tuesday, 3 February 2015 at 05:09:55 UTC, Ali Çehreli wrote:
Yes, it's a known bug that has been fixed on git head but I
can't find the bug report. :-/
Ok cool, good to know.
The new output:
foo
destoy
Yes, without the 'r'. ;)
Ali
Yeah, i noticed the typo right after I posted...
On 02/02/2015 07:51 PM, Tofu Ninja wrote:
module main;
import std.stdio;
void main(string[] args)
{
with(test())
{
foo();
}
}
struct test
{
void foo()
{
writeln("foo");
}
~this()
{
writeln("destoy");
}
}
prints:
destro
19 matches
Mail list logo