Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

removed finalize methods because of a hint in http://java.sun.com/javase/6/webnotes/trouble/TSG-VM/html/memleaks.html#gbyvh

orbiter4cd5418963b0
diff --git a/source/de/anomic/crawler/CrawlProfile.java b/source/de/anomic/crawler/CrawlProfile.java
index b530748b2..954acb2df 100644
--- a/source/de/anomic/crawler/CrawlProfile.java
+++ b/source/de/anomic/crawler/CrawlProfile.java
@@ -85,11 +85,6 @@ public class CrawlProfile {
this.profileTable = null;
}
- @Override
- public void finalize() {
- this.close();
- }
-
public int size() {
return profileTable.size();
}
diff --git a/source/de/anomic/http/server/ResponseContainer.java b/source/de/anomic/http/server/ResponseContainer.java
index d2c4f5554..3cc2d1d9e 100644
--- a/source/de/anomic/http/server/ResponseContainer.java
+++ b/source/de/anomic/http/server/ResponseContainer.java
@@ -176,14 +176,4 @@ public class ResponseContainer {
public void setAccountingName(final String accName) {
incomingAccountingName = accName;
}
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#finalize()
- */
- @Override
- protected void finalize() {
- closeStream();
- }
}
diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.java
index 551681ca1..beacb2314 100644
--- a/source/de/anomic/server/serverCore.java
+++ b/source/de/anomic/server/serverCore.java
@@ -656,10 +656,6 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
}
- protected void finalize() {
- this.close();
- }
-
private void listen() {
try {
// start dialog
diff --git a/source/net/yacy/document/Document.java b/source/net/yacy/document/Document.java
index e884c71cd..b59d69c5c 100644
--- a/source/net/yacy/document/Document.java
+++ b/source/net/yacy/document/Document.java
@@ -590,10 +590,5 @@ dc_rights
}
}
}
-
- protected void finalize() throws Throwable {
- this.close();
- super.finalize();
- }
}
diff --git a/source/net/yacy/document/parser/html/AbstractScraper.java b/source/net/yacy/document/parser/html/AbstractScraper.java
index bd8a515c0..05e811d07 100644
--- a/source/net/yacy/document/parser/html/AbstractScraper.java
+++ b/source/net/yacy/document/parser/html/AbstractScraper.java
@@ -95,11 +95,6 @@ public abstract class AbstractScraper implements Scraper {
tags1 = null;
}
- @Override
- protected void finalize() {
- close();
- }
-
}
diff --git a/source/net/yacy/document/parser/html/AbstractTransformer.java b/source/net/yacy/document/parser/html/AbstractTransformer.java
index 16e39ab52..20fefbdb8 100644
--- a/source/net/yacy/document/parser/html/AbstractTransformer.java
+++ b/source/net/yacy/document/parser/html/AbstractTransformer.java
@@ -67,10 +67,5 @@ public abstract class AbstractTransformer implements Transformer {
tags0 = null;
tags1 = null;
}
-
- @Override
- protected void finalize() {
- close();
- }
}
diff --git a/source/net/yacy/document/parser/html/TransformerWriter.java b/source/net/yacy/document/parser/html/TransformerWriter.java
index 8bf05c9cd..81d4e49db 100644
--- a/source/net/yacy/document/parser/html/TransformerWriter.java
+++ b/source/net/yacy/document/parser/html/TransformerWriter.java
@@ -530,13 +530,6 @@ public final class TransformerWriter extends Writer {
// if you want to flush all, call close() at end of writing;
}
- @Override
- protected void finalize() throws IOException {
- // if we are forced to close, we of course flush the buffer first,
- // then close the connection
- close();
- }
-
public void close() throws IOException {
final char quotechar = (inSingleQuote) ? singlequote : doublequote;
if (buffer != null) {
diff --git a/source/net/yacy/kelondro/index/RowSet.java b/source/net/yacy/kelondro/index/RowSet.java
index 8f7661cba..06ae061b8 100644
--- a/source/net/yacy/kelondro/index/RowSet.java
+++ b/source/net/yacy/kelondro/index/RowSet.java
@@ -76,9 +76,11 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable<Row.E
final int orderbound = (int) NaturalOrder.decodeLong(b, 10, 4);
assert orderbound >= 0 : "orderbound = " + orderbound;
if (orderbound < 0) return new RowSet(rowdef); // error
- final byte[] chunkcache = new byte[size * rowdef.objectsize];
+ long alloc = ((long) size) * ((long) rowdef.objectsize);
+ assert alloc <= Integer.MAX_VALUE : "alloc = " + alloc;
+ final byte[] chunkcache = new byte[(int) alloc];
//assert b.length - exportOverheadSize == size * rowdef.objectsize : "b.length = " + b.length + ", size * rowdef.objectsize = " + size * rowdef.objectsize;
- if (b.length - exportOverheadSize != size * rowdef.objectsize) {
+ if (b.length - exportOverheadSize != alloc) {
Log.logSevere("RowSet", "exportOverheadSize wrong: b.length = " + b.length + ", size * rowdef.objectsize = " + size * rowdef.objectsize);
return new RowSet(rowdef);
}
diff --git a/source/net/yacy/kelondro/io/ByteCountInputStream.java b/source/net/yacy/kelondro/io/ByteCountInputStream.java
index 44219580e..00253f396 100644
--- a/source/net/yacy/kelondro/io/ByteCountInputStream.java
+++ b/source/net/yacy/kelondro/io/ByteCountInputStream.java
@@ -143,10 +143,4 @@ public final class ByteCountInputStream extends FilterInputStream {
byteCountInfo.clear();
}
}
-
- protected final void finalize() throws Throwable {
- if (!this.finished)
- finish();
- super.finalize();
- }
}
diff --git a/source/net/yacy/kelondro/io/ByteCountOutputStream.java b/source/net/yacy/kelondro/io/ByteCountOutputStream.java
index f67cb5368..87238027f 100644
--- a/source/net/yacy/kelondro/io/ByteCountOutputStream.java
+++ b/source/net/yacy/kelondro/io/ByteCountOutputStream.java
@@ -132,9 +132,4 @@ public final class ByteCountOutputStream extends BufferedOutputStream {
}
}
- protected final void finalize() throws Throwable {
- if (!this.finished)
- finish();
- super.finalize();
- }
}
diff --git a/source/net/yacy/kelondro/rwi/ReferenceIterator.java b/source/net/yacy/kelondro/rwi/ReferenceIterator.java
index 60878d15a..4cdc2ce3f 100644
--- a/source/net/yacy/kelondro/rwi/ReferenceIterator.java
+++ b/source/net/yacy/kelondro/rwi/ReferenceIterator.java
@@ -82,10 +82,6 @@ public class ReferenceIterator <ReferenceType extends Reference> implements Clon
if (blobs != null) this.blobs.close();
blobs = null;
}
-
- protected void finalize() {
- this.close();
- }
public CloneableIterator<ReferenceContainer<ReferenceType>> clone(Object modifier) {
if (blobs != null) this.blobs.close();
diff --git a/source/net/yacy/kelondro/util/XMLTables.java b/source/net/yacy/kelondro/util/XMLTables.java
index 91bbc6459..8b2dec288 100644
--- a/source/net/yacy/kelondro/util/XMLTables.java
+++ b/source/net/yacy/kelondro/util/XMLTables.java
@@ -164,10 +164,4 @@ public class XMLTables {
commit(true);
}
- // we finalize the operation by saving everything throug the scheduler
- // this method is called by the java GC bevore it destroys the object
- protected void finalize() throws IOException {
- close();
- }
-
}