Extreme memory usage when `synchronized( this )` is used
tcak via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon May 11 02:40:28 PDT 2015
On Monday, 11 May 2015 at 09:20:50 UTC, Daniel Kozák wrote:
>
> On Mon, 11 May 2015 09:09:07 +0000
> tcak via Digitalmars-d-learn
> <digitalmars-d-learn at puremagic.com> wrote:
>
>
> I think synchronize(this) prevents GC from collect memory
I am not sure whether this is expected behaviour from
`synchronization` keyword.
Similar code in Java. It has settled on about 62M and didn't
increase at all.
[code]
public class Main{
private void other(){}
public void close(){
synchronized( this ){
other();
}
}
public void hasData(){ System.out.println("Has Data"); }
public static void main( String[] args ){
for(long i=0; i < 250000000; ++i){
Main conn = new Main();
conn.hasData();
conn.close();
conn = null;
}
}
}
[/code]
More information about the Digitalmars-d-learn
mailing list