How to release memory? (D2.0.30)

2009-07-03 Thread AxelS
Hello everyone, I've got a problem with the following (very simple) code: void foo() { void[] dat=new void[50_000_000]; // allocate 50 MByte of dummy-data delete dat; } after I called foo() and watched the memory usage in the windows taskmanager, the program blowed up to 50 MBytes al

Re: How to release memory? (D2.0.30)

2009-07-03 Thread Jarrett Billingsley
On Fri, Jul 3, 2009 at 4:30 PM, AxelS wrote: > Hello everyone, > I've got a problem with the following (very simple) code: > > void foo() > { >      void[] dat=new void[50_000_000]; // allocate 50 MByte of dummy-data >      delete dat; > } > > after I called foo() and watched the memory usage in th

Re: How to release memory? (D2.0.30)

2009-07-03 Thread BCS
Reply to AxelS, Hello everyone, I've got a problem with the following (very simple) code: void foo() { void[] dat=new void[50_000_000]; // allocate 50 MByte of dummy-data delete dat; } after I called foo() and watched the memory usage in the windows taskmanager, the program blowed up to 50 MByte

Re: How to release memory? (D2.0.30)

2009-07-03 Thread bearophile
AxelS: > void[] dat=new void[50_000_000]; // allocate 50 MByte of dummy-data I am not sure, but the GC may scan that chunk of voids. If you need a raw block it may be better to work with an array of uint. > Why can't the GC remove that data and how CAN I remove it? If you really need to

Re: How to release memory? (D2.0.30)

2009-07-04 Thread AxelS
BCS Wrote: > You can't. The D runtime (and most other runtimes) don't ever reduce the > amount of memory they keep in the heap. If you where to allocate another > 25MB right after that function you would see no change in the memory usage. > The good news is that with virtual memory, all of that

Re: How to release memory? (D2.0.30)

2009-07-04 Thread Daniel Keep
BCS wrote: > ... The good news is that with virtual memory, all of that has almost > zero cost. What matters is how much ram you are actively using. You've obviously never used a netbook with no swap file. :)

Re: How to release memory? (D2.0.30)

2009-07-04 Thread Ary Borenszweig
AxelS escribió: BCS Wrote: You can't. The D runtime (and most other runtimes) don't ever reduce the amount of memory they keep in the heap. If you where to allocate another 25MB right after that function you would see no change in the memory usage. The good news is that with virtual memory, a

Re: How to release memory? (D2.0.30)

2009-07-04 Thread AxelS
@Ary Borenszweig: Good idea but I can't pipe data to a HTTP-server located somewhere in the internet... OK, I tried it with C's malloc and free - but everytime I access my array, D puts the memory into its heap...I'm getting crazy because of this! ubyte[] data=cast(ubyte[])malloc(50_000_000)[0

Re: How to release memory? (D2.0.30)

2009-07-04 Thread Daniel Keep
AxelS wrote: > @Ary Borenszweig: Good idea but I can't pipe data to a HTTP-server located > somewhere in the internet... I believe he means to read the file in chunks, sending them across the network as you get them. > OK, I tried it with C's malloc and free - but everytime I access my array,

Re: How to release memory? (D2.0.30)

2009-07-04 Thread BCS
Hello Daniel, BCS wrote: ... The good news is that with virtual memory, all of that has almost zero cost. What matters is how much ram you are actively using. You've obviously never used a netbook with no swap file. :) Nope, my netbook has a swap file, and I've never heard of one befor (

Re: How to release memory? (D2.0.30)

2009-07-04 Thread BCS
Hello AxelS, BCS Wrote: You can't. The D runtime (and most other runtimes) don't ever reduce the amount of memory they keep in the heap. If you where to allocate another 25MB right after that function you would see no change in the memory usage. The good news is that with virtual memory, all o

Re: How to release memory? (D2.0.30)

2009-07-05 Thread downs
BCS wrote: > Hello AxelS, > >> BCS Wrote: >> >>> You can't. The D runtime (and most other runtimes) don't ever reduce >>> the amount of memory they keep in the heap. If you where to allocate >>> another 25MB right after that function you would see no change in the >>> memory usage. The good news i

Re: How to release memory? (D2.0.30)

2009-07-05 Thread AxelS
@downs: That's what I even had beforejust allocate and release memory is not difficult - just if you want to access the data the GC copies all the memory into its heap... I found a new way which is really good and easy: Just use the Win32 Memory API for allocating and releasing your data wi

Re: How to release memory? (D2.0.30)

2009-07-05 Thread Jérôme M. Berger
downs wrote: BCS wrote: Hello AxelS, BCS Wrote: You can't. The D runtime (and most other runtimes) don't ever reduce the amount of memory they keep in the heap. If you where to allocate another 25MB right after that function you would see no change in the memory usage. The good news is that

Re: How to release memory? (D2.0.30)

2009-07-05 Thread Tom S
AxelS wrote: @downs: That's what I even had beforejust allocate and release memory is not difficult - just if you want to access the data the GC copies all the memory into its heap... Can you recommend a good crack dealer? ;) Seriously, there are no GC calls associated with memory acces

Re: How to release memory? (D2.0.30)

2009-07-05 Thread BCS
Hello Jérôme, Like BCS said, the only way to make sure that the memory will be returned is to use mmap/munmap directly (or their equivalent on your platform). That maybe true, but it wasn't my point. What I was trying to get at was that if you want to load a file into a buffer then asking mma

Re: How to release memory? (D2.0.30)

2009-07-07 Thread Steven Schveighoffer
On Sat, 04 Jul 2009 05:11:39 -0400, Daniel Keep wrote: BCS wrote: ... The good news is that with virtual memory, all of that has almost zero cost. What matters is how much ram you are actively using. You've obviously never used a netbook with no swap file. :) Swap files are needed for

Re: How to release memory? (D2.0.30)

2009-07-07 Thread BCS
Reply to Steven, On Sat, 04 Jul 2009 05:11:39 -0400, Daniel Keep wrote: BCS wrote: ... The good news is that with virtual memory, all of that has almost zero cost. What matters is how much ram you are actively using. You've obviously never used a netbook with no swap file. :) Swap file