Prevent Garbage Collector
Jeroen Bollen
jbinero at gmail.com
Sat Jan 4 09:19:29 PST 2014
On Saturday, 4 January 2014 at 17:16:53 UTC, Adam D. Ruppe wrote:
> On Saturday, 4 January 2014 at 17:15:12 UTC, Jeroen Bollen
> wrote:
>> Is there a way to prevent the Garbage collector from running
>> on one particular object? Something like:
>
> I would just malloc it.
>
> int* CreatePermanentInt() {
> int* i = malloc(int.sizeof);
> *i = 5;
> return i;
> }
>
>
> The malloced thing itself won't be freed, nor will its contents
> be scanned by the gc (unless you use GC.addRange yourself) so
> you can use it to hack some weak references too.
Do I get malloc from the C library or does D also have a function
for this?
More information about the Digitalmars-d-learn
mailing list