Re: buff = new StringBuffer(10000); buff.toString(); Will GC be complete here?
From: Chris Uppal (chris.uppal_at_metagnostic.REMOVE-THIS.org)
Date: 02/18/04
- Next message: Andrew Thompson: "Re: Cannot access class"
- Previous message: James: "Re: Cannot access class"
- In reply to: Chris Smith: "Re: buff = new StringBuffer(10000); buff.toString(); Will GC be complete here?"
- Next in thread: Thomas G. Marshall: "Re: buff = new StringBuffer(10000); buff.toString(); Will GC be complete here?"
- Reply: Thomas G. Marshall: "Re: buff = new StringBuffer(10000); buff.toString(); Will GC be complete here?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 18 Feb 2004 12:03:30 -0000
Chris Smith wrote:
> There are three objects involved for each iteration of the loop in main:
> a StringBuffer, a String, and a (internal) char[] which is used to hold
> the real character data.
Well, whatdya know ?
I was about to reply that I thought there must be at least four. The
StringBuffer, its large internal char[] array, the String object, and its small
internal char[] array. Since the String is not allowed to change when the
contents of the StringBuffer are changed, it is not possible for the two
objects to share a common char[] buffer.
But it turns out that the Sun implementation *does* share the buffer, but marks
it copy-on-write in the StringBuffer object.
Live and learn...
Thanks.
-- chris
- Next message: Andrew Thompson: "Re: Cannot access class"
- Previous message: James: "Re: Cannot access class"
- In reply to: Chris Smith: "Re: buff = new StringBuffer(10000); buff.toString(); Will GC be complete here?"
- Next in thread: Thomas G. Marshall: "Re: buff = new StringBuffer(10000); buff.toString(); Will GC be complete here?"
- Reply: Thomas G. Marshall: "Re: buff = new StringBuffer(10000); buff.toString(); Will GC be complete here?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|