free some memory after parsing html

pull/1/head
Michael Peter Christen 13 years ago
parent 4540174fe0
commit 7e4e3fe5b6

@ -131,6 +131,7 @@ public class ContentScraper extends AbstractScraper implements Scraper {
private float lon, lat; private float lon, lat;
private MultiProtocolURI canonical; private MultiProtocolURI canonical;
/** /**
* {@link MultiProtocolURI} to the favicon that belongs to the document * {@link MultiProtocolURI} to the favicon that belongs to the document
*/ */
@ -175,6 +176,11 @@ public class ContentScraper extends AbstractScraper implements Scraper {
this.canonical = null; this.canonical = null;
} }
@Override
public void finish() {
this.content.trimToSize();
}
private void mergeAnchors(final MultiProtocolURI url, final Properties p) { private void mergeAnchors(final MultiProtocolURI url, final Properties p) {
final Properties p0 = this.anchors.get(url); final Properties p0 = this.anchors.get(url);
if (p0 == null) { if (p0 == null) {

@ -1,4 +1,4 @@
// Scraper.java // Scraper.java
// --------------------------- // ---------------------------
// (C) by Michael Peter Christen; mc@yacy.net // (C) by Michael Peter Christen; mc@yacy.net
// first published on http://www.anomic.de // first published on http://www.anomic.de
@ -39,10 +39,12 @@ public interface Scraper {
public void scrapeTag1(String tagname, Properties tagopts, char[] text); public void scrapeTag1(String tagname, Properties tagopts, char[] text);
public void scrapeComment(final char[] comment); public void scrapeComment(final char[] comment);
public void finish();
public void close(); public void close();
public void registerHtmlFilterEventListener(ScraperListener listener); public void registerHtmlFilterEventListener(ScraperListener listener);
public void deregisterHtmlFilterEventListener(ScraperListener listener); public void deregisterHtmlFilterEventListener(ScraperListener listener);
} }

@ -534,8 +534,7 @@ public final class TransformerWriter extends Writer {
this.filterOpts = null; this.filterOpts = null;
if (this.filterCont != null) this.filterCont.close(); if (this.filterCont != null) this.filterCont.close();
this.filterCont = null; this.filterCont = null;
// if (scraper != null) {scraper.close(); scraper = null;} if (this.scraper != null) this.scraper.finish();
// if (transformer != null) {transformer.close(); transformer = null;}
} }
private static boolean binaryHint(final char c) { private static boolean binaryHint(final char c) {

@ -73,27 +73,6 @@ public final class CharBuffer extends Writer {
this.maximumLength = maximumLength; this.maximumLength = maximumLength;
} }
public CharBuffer(final int maximumLength, final char[] bb, final int of, final int le) {
if (of * 2 > bb.length) {
this.buffer = new char[le];
System.arraycopy(bb, of, this.buffer, 0, le);
this.length = le;
this.offset = 0;
} else {
this.buffer = bb;
this.length = le;
this.offset = of;
}
this.maximumLength = maximumLength;
}
public CharBuffer(final CharBuffer bb) {
this.buffer = bb.buffer;
this.length = bb.length;
this.offset = bb.offset;
this.maximumLength = bb.maximumLength;
}
public CharBuffer(final File f) throws IOException { public CharBuffer(final File f) throws IOException {
// initially fill the buffer with the content of a file // initially fill the buffer with the content of a file
if (f.length() > Integer.MAX_VALUE) throw new IOException("file is too large for buffering"); if (f.length() > Integer.MAX_VALUE) throw new IOException("file is too large for buffering");

@ -365,6 +365,7 @@ public final class yacyRelease extends yacyVersion {
try { try {
final CharBuffer signBuffer = new CharBuffer(getSignatureFile()); final CharBuffer signBuffer = new CharBuffer(getSignatureFile());
final byte[] signByteBuffer = Base64Order.standardCoder.decode(signBuffer.toString().trim()); final byte[] signByteBuffer = Base64Order.standardCoder.decode(signBuffer.toString().trim());
signBuffer.close();
final CryptoLib cl = new CryptoLib(); final CryptoLib cl = new CryptoLib();
for(final yacyUpdateLocation updateLocation : latestReleaseLocations) { for(final yacyUpdateLocation updateLocation : latestReleaseLocations) {
try { try {

Loading…
Cancel
Save