[ajug-members] asked a different way
Steve Finch
Sfinch at manh.com
Fri Sep 12 09:19:01 EDT 2008
Micro-benchmarks are almost impossible to do in Java. Brian Goetz
addressed this in articles and in "Java Concurrency in Practice"
http://www.ibm.com/developerworks/java/library/j-jtp02225.html
If you really want to know what's going on, as Mike said, use JConsole.
If you are using Java 5, there's some cmd line parameters to add.
http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html
-----Original Message-----
From: Wilson, Jeff [mailto:jw9615 at att.com]
Sent: Friday, September 12, 2008 8:45 AM
To: ajug-members at ajug.org; Burr Sutter
Subject: Re: [ajug-members] asked a different way
If I'm reading your program correctly, you aren't actually allocating
any objects. The statement:
Rational fraction;
Allocates only enough memory to hold a reference -- its essentially a
pointer, so it probably is on the order of 4 bytes. It doesn't actually
allocate an object.
Try changing it to:
Rational fraction = new Rational();
And see what happens. However, even that is not guaranteed to allocate
any memory because the VM can optimize this allocation away since the
object is never used.
A more interesting test might be to do the following:
List<Rational> fractions = new ArrayList<Rational>();
for (int I = 0; i< 100; i++) {
fractions.add(new Rational());
println(runtime.freeMemory());
}
fractions.empty();
println(runtime.freeMemory());
+jeff (MJW)
---
"If you are going through hell, keep going."
-W. Churchill
---------------------------------------------
M. Jeff Wilson, Lead Member Technical Staff
AT&T Services, Inc.
Operations & Service Dev
jw9615 at att.com
+1 404.499.7235
-----Original Message-----
From: mcdaniel [mailto:521 at ofig.org]
Sent: Thursday, September 11, 2008 5:45 AM
To: Burr Sutter; ajug-members at ajug.org
Subject: [ajug-members] asked a different way
why does this post/attached not show up on the ajug user/mail group?
thanks
barclay
>>>>>>>>>>>>>>
let me ask this then, how can i display the amt of free-memory
before/after 10000 Rational objects are allocated, then not saved in a
variable- which makes them garbage? per (near how) the *attached*
screen-shot (fails to show)
barclay
barclay
*****
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential, proprietary, and/or
privileged material. Any review, retransmission, dissemination or other
use of, or taking of any action in reliance upon this information by
persons or entities other than the intended recipient is prohibited. If
you received this in error, please contact the sender and delete the
material from all computers. GA623
_______________________________________________
ajug-members mailing list
ajug-members at ajug.org
http://www.ajug.org/mailman/listinfo/ajug-members
More information about the ajug-members
mailing list