🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #75495

Re: forcing finalize()

#75495
From: Lionel W. Penton
Date: Mon, 12 Mar 2007 00:25
91 lines
4362 bytes
In article <45ce0e0d$0$49206$14726298@news.sunsite.dk>,
=?ISO-8859-1?Q?Arne_Vajh=F8j?= <arne@vajhoej.dk> wrote:
>nukleus wrote:
>> Btw, I just read some posts on memory allocation/deallocation issues,
>> and I did not quite expect the behavior described.
>>
>> I thought that object is gc'ed when there are no references left.
>
>Java does not use reference counting.
>
>Objects that are not reachable from the executing program can be
>GC'ed.

Interesting. But how do they know they are not reachable?

>> So, if i have a multi-variable object, containing strings,
>> buffers, etc. and I put those objects in a Vector,
>> for the sake of argument, and, i do setElementAt() and set
>> it to null, i thought it becomes a subject to gc,
>> and, once it is gc'ed, all the buffers, strings, etc.,
>> it contains become subject to gc also.
>
>The GC can/should GC them all in one sweep.

Thanks god.

>> Secondly, if i have a string and then set it to a new value,
>> does the old value become a subject to gc?
>
>Yes.
>
>> Sting s = "abc";
>> s = "def";
>
>There are some special handling for string literals where Java
>only have one object for the same literal.

Well, i didn't mean string literal,
but string as such.

>> What happens to "abc" string in terms of deallocation?
>> Is it the same as new String("def")
>> meaning that there is no longer a reference
>> to "abc" and it, therefore, is subject to gc?

>Ignoring the special handling of String literals, then
>as soon as there are no way to reach an object it can be GC'ed.

Sorry, but I don't get it.
How does it know it can't reach something?

>> How do I release memory held by StringBuffer?
>
>Just let the reference run out of scope.

Well, but when I am in a loop, reusing the same string
buffer that has large amounts of buffer for each iteration,
what happens to the old data?
Should I just create a new buffer every iteration
just to make sure the old stuff gets gc'ed?
I am talking about 10s of megs of data being shuffled.

>> When I set its size to 0 and start accumulating
>> a new data in it, what happens to the old data?
>> Is it gc'ed?
>
>Depends on the implementation. You can look it up whether
>it reuses the backing storage or not. I have not checked
>it out myself. You should not code after that kind of
>implementation issues.

Thanks.

>Arne




- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
On Purim, Feb. 25, 1994, Israeli army officer
Baruch Goldstein, an orthodox Jew from Brooklyn,
massacred 40 Palestinian civilians, including children,
while they knelt in prayer in a mosque.

Subsequently, Israeli's have erected a statue to this -
his good work - advancing the Zionist Cause.

Goldstein was a disciple of the late Brooklyn
that his teaching that Arabs are "dogs" is derived
"from the Talmud." (CBS 60 Minutes, "Kahane").
Technical Details
Message-ID: <1210118714244708@215.233.5.248>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!news.glorb.com!news2.dg.net.ua!news.ett.com.ua!news.te.net.ua!postnews.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!130.81.64.211.MISMATCH!cycny01.gnilink.net!spamkiller2.gnilink.net!gnilink.net!trndny04.POSTED!760c3fd9!ucla.edu!angry
References: <1171110687.730783.211690@q2g2000cwa.googlegroups.com> <5369psF1rc5p5U1@mid.individual.net> <eqkv02$hl6$3@sage.ukr.net> <45ce0e0d$0$49206$14726298@news.sunsite.dk>

Show Full Headers
Complete Article Headers
Message-ID: <1210118714244708@215.233.5.248>
Subject: Re: forcing finalize()
Date: Mon, 12 Mar 2007 00:25:51 GMT
From: "Lionel W. Penton" <angry@ucla.edu>
References: <1171110687.730783.211690@q2g2000cwa.googlegroups.com> <5369psF1rc5p5U1@mid.individual.net> <eqkv02$hl6$3@sage.ukr.net> <45ce0e0d$0$49206$14726298@news.sunsite.dk>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!news.glorb.com!news2.dg.net.ua!news.ett.com.ua!news.te.net.ua!postnews.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!130.81.64.211.MISMATCH!cycny01.gnilink.net!spamkiller2.gnilink.net!gnilink.net!trndny04.POSTED!760c3fd9!ucla.edu!angry
Newsgroups: news.groups, alt.slack, alt.config, news.software.nntp, alt.usenet.kooks
 alt.usenet.kooks
Organization: Freemason's Against All
Lines: 91
NNTP-Posting-Host: d50-75.tenet.odessa.ua
X-Trace: toster.te.net.ua 1173679212 27928 195.138.75.50 (12 Mar 2007 06:00:12
 GMT)
X-Complaints-To: abuse@te.net.ua
NNTP-Posting-Date: Mon, 12 Mar 2007 06:00:12 +0000 (UTC)
X-Newsreader: Microsoft Outlook Express 4.72.3110.1