| Thread overview | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
July 12, 2010 I want my Memory back ;-) | ||||
|---|---|---|---|---|
| ||||
Hi everyone, I don't know if it's a bug or not .. but D or at least its GC doesn't want to free my allocated stuff! Also when I 'disable' the GC via GC.disable(); it won't free it :-/ byte[] asdf=new byte[50_000_000]; // OK a bit much---but it's an example value GC.free(&asdf); // It doesn't work!! delete asdf; // Also, without GC.free, doesn't work!!! So...please give me a solution for this, D people :-D --Alex | ||||
July 13, 2010 Re: I want my Memory back ;-) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to ABothe | == Quote from ABothe (info@alexanderbothe.com)'s article
> Hi everyone,
> I don't know if it's a bug or not .. but D or at least its GC doesn't want to
> free my allocated stuff! Also when I 'disable' the GC via GC.disable(); it
> won't free it :-/
> byte[] asdf=new byte[50_000_000]; // OK a bit much---but it's an example value
> GC.free(&asdf); // It doesn't work!!
> delete asdf; // Also, without GC.free, doesn't work!!!
> So...please give me a solution for this, D people :-D
> --Alex
GC.free(cast(void*) asdf.ptr);
| |||
July 13, 2010 Re: I want my Memory back ;-) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to ABothe | ABothe, el 12 de julio a las 23:44 me escribiste: > Hi everyone, > > I don't know if it's a bug or not .. but D or at least its GC doesn't want to free my allocated stuff! Also when I 'disable' the GC via GC.disable(); it won't free it :-/ Disable that exactly that, force the GC *not* to run a collection. > byte[] asdf=new byte[50_000_000]; // OK a bit much---but it's an example value This is a clasical problem of the conservative GC. The problem is, false pointers would keep your large chunks of memory alive (the bigger the chunk, the higher the probability of a random word being confused as a pointer into it). There were some solutions proposed, but none accepted yet: http://d.puremagic.com/issues/show_bug.cgi?id=2927 http://d.puremagic.com/issues/show_bug.cgi?id=3463 > GC.free(&asdf); // It doesn't work!! > delete asdf; // Also, without GC.free, doesn't work!!! Those 2 *must* work. What are you doing to check if they work? -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- There is no pain you are receding A distant ship, smoke on the horizon. You are only coming through in waves. Your lips move but I can't hear what you're saying. | |||
July 13, 2010 Re: I want my Memory back ;-) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Leandro Lucarella | Hello Leandro, > ABothe, el 12 de julio a las 23:44 me escribiste: > >> GC.free(&asdf); // It doesn't work!! >> delete asdf; // Also, without GC.free, doesn't work!!! > Those 2 *must* work. What are you doing to check if they work? > If, by chance, you are looking at the memory usage of your program (i.e. the amount of space the OS has mapped) as reported by the OS or the like, then you won't see anything as the GC never returns memory to the OS, OTOH unless you are VERY tight on memory, this will have negligible effect on most modern computers. -- ... <IXOYE>< | |||
July 13, 2010 Re: I want my Memory back ;-) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Leandro Lucarella | First, thanks for the response! When executing the program at your own, look at the task manager... It simply doesn't do it! Is there somebody who can make it possible for the GC to give allocated memory right back?? | |||
July 13, 2010 Re: I want my Memory back ;-) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to ABothe | ABothe:
> Is there somebody who can make it possible for the GC to give allocated memory right back??
In Python generally this doesn't happen.
Bye,
bearophile
| |||
July 13, 2010 Re: I want my Memory back ;-) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to bearophile | So there isn't any other method than calling C's free(); or malloc (); ? | |||
July 13, 2010 Re: I want my Memory back ;-) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to ABothe | On Tue, 13 Jul 2010 03:50:19 -0400, ABothe <info@asdf.com> wrote:
> First, thanks for the response!
>
> When executing the program at your own, look at the task
> manager... It simply doesn't do it!
>
>
> Is there somebody who can make it possible for the GC to give
> allocated memory right back??
The GC does not release memory back to the OS in all circumstances, it may hold onto the memory, even though it isn't allocated.
Part of the reason for this is it may just not be possible. IIRC, on Linux systems, all your heap-allocated memory must be contiguous, meaning that if you deallocate holes, you can't release them back to the OS.
There is also a design bug in the array allocator (which you probably have not encountered, since you did not append), where it will hold onto memory even if nothing is referencing it because the LRU cache is referencing it. I am going to fix that in the near future.
-Steve
| |||
July 13, 2010 Re: I want my Memory back ;-) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to ABothe | On 13.07.2010 12:28, ABothe wrote:
> So there isn't any other method than calling C's free(); or malloc
> (); ?
That's how it is.
| |||
July 13, 2010 Re: I want my Memory back ;-) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to ABothe | ABothe, el 13 de julio a las 07:50 me escribiste: > First, thanks for the response! > > When executing the program at your own, look at the task manager... It simply doesn't do it! > > Is there somebody who can make it possible for the GC to give allocated memory right back?? Calling gc.minimize() should free memory (as give it back to the OS) if there are any pools completely free, but IFAIK is only implemented in Tango and D2 (i.e., not implemented in Phobos/D1). -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- La esperanza es una amiga que nos presta la ilusión. | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply