You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ha...@apache.org on 2002/04/01 11:10:42 UTC
cvs commit: jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test MemoryLeakClientTest.java MemoryLeakImpl.java
hammant 02/04/01 01:10:42
Modified: altrmi/src/java/org/apache/commons/altrmi/test
MemoryLeakClientTest.java MemoryLeakImpl.java
Log:
small changes to readability of memleak test
Revision Changes Path
1.5 +14 -3 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeakClientTest.java
Index: MemoryLeakClientTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeakClientTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MemoryLeakClientTest.java 31 Mar 2002 21:24:29 -0000 1.4
+++ MemoryLeakClientTest.java 1 Apr 2002 09:10:42 -0000 1.5
@@ -19,6 +19,7 @@
import org.apache.commons.altrmi.client.impl.ClientClassAltrmiFactory;
import java.io.IOException;
+import java.util.Vector;
/**
@@ -26,7 +27,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class MemoryLeakClientTest {
@@ -39,10 +40,20 @@
*/
public MemoryLeakClientTest(MemoryLeak ml) {
+ // if you enable the vector, then serverside
+ // memory usage ramps as MemoryLeak instances
+ // are not garbage collected.
+ //Vector v = new Vector();
+
long start = System.currentTimeMillis();
for (int i = 0; i < 100000000; i++) {
- MemoryLeak tmpMl = ml.getNewMemoryLeak();
- ml.getHugeString(); // this does not seem to affect speed.
+ //v.add(ml);
+ ml = ml.getNewMemoryLeak();
+ // this seems to halve the speed.
+ // but also is proven to be GC'd well for
+ // custom stream. For ObjectStream it is
+ // a different measure.
+ //ml.getHugeString();
System.gc(); // pointless ?
if (i%100 == 0) {
1.4 +6 -11 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeakImpl.java
Index: MemoryLeakImpl.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeakImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MemoryLeakImpl.java 31 Mar 2002 21:24:29 -0000 1.3
+++ MemoryLeakImpl.java 1 Apr 2002 09:10:42 -0000 1.4
@@ -15,11 +15,10 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class MemoryLeakImpl implements MemoryLeak {
- private String mHugeStr = "";
/**
* Constructor MemoryLeakImpl
@@ -27,14 +26,6 @@
*
*/
MemoryLeakImpl() {
-
- StringBuffer sb = new StringBuffer();
-
- for (int i = 0; i < 1000; i++) {
- sb.append("" + i);
- }
-
- mHugeStr = sb.toString();
}
/**
@@ -59,7 +50,11 @@
*
*/
public String getHugeString() {
- return mHugeStr;
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < 1000; i++) {
+ sb.append("" + i);
+ }
+ return sb.toString();
}
protected void finalize() throws Throwable {
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>