01: /*
02: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: * [See end of file]
04: */
05:
06: package com.hp.hpl.jena.rdf.arp.test;
07:
08: import java.io.IOException;
09: import java.io.OutputStream;
10: import java.io.PrintStream;
11:
12: import junit.framework.Test;
13: import junit.framework.TestCase;
14: import junit.framework.TestSuite;
15:
16: import com.hp.hpl.jena.rdf.arp.NTriple;
17:
18: public class MemoryLeakTest extends TestCase {
19:
20: static public Test suite() {
21: TestSuite suite = new TestSuite("ARP Memory Leak");
22:
23: suite.addTest(new MemoryLeakTest("testWineMemoryLeak"));
24: return suite;
25: }
26:
27: public MemoryLeakTest(String arg0) {
28: super (arg0);
29: }
30:
31: public void testWineMemoryLeak() throws IOException {
32: // warmup
33: Runtime rt = Runtime.getRuntime();
34: loadFile("testing/wg/miscellaneous/consistent001.rdf");
35: rt.gc();
36: rt.gc();
37: rt.gc();
38: long inUse = rt.totalMemory() - rt.freeMemory();
39: loadFile("testing/arp/wineRenamed.rdf");
40: rt.gc();
41: rt.gc();
42: rt.gc();
43: long leaked = rt.totalMemory() - rt.freeMemory() - inUse;
44: System.err.println("Leaked: " + leaked);
45:
46: }
47:
48: static void loadFile(String fileName) throws IOException {
49: PrintStream out = new PrintStream(new OutputStream() {
50:
51: public void write(int b) throws IOException {
52: }
53: });
54: PrintStream oldOut = System.out;
55: try {
56: System.setOut(out);
57: NTriple.mainEh(new String[] { "-b", "http://eg.org/", "-t",
58: fileName }, null, null);
59: out.close();
60: } finally {
61: System.setOut(oldOut);
62:
63: }
64: }
65:
66: }
67:
68: /*
69: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
70: * All rights reserved.
71: *
72: * Redistribution and use in source and binary forms, with or without
73: * modification, are permitted provided that the following conditions
74: * are met:
75: * 1. Redistributions of source code must retain the above copyright
76: * notice, this list of conditions and the following disclaimer.
77: * 2. Redistributions in binary form must reproduce the above copyright
78: * notice, this list of conditions and the following disclaimer in the
79: * documentation and/or other materials provided with the distribution.
80: * 3. The name of the author may not be used to endorse or promote products
81: * derived from this software without specific prior written permission.
82: *
83: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
84: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
85: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
86: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
87: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
88: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
89: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
90: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
91: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
92: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
93: */
|