|
|
|
1000 Java Tips ebook
|
|
 

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java
programming articles and tips. Please take your copy here.
Take your copy of free "Java Technology Screensaver"!. |
|
Easy Learn Java: Programming Articles, Examples and Tips - Page 396
Previous
1060 Stories (530 Pages, 2 Per Page)
Next
Counting Objects Clandestinely - Follow-up
|
h4 Java Specialists' Newsletter [Issue 038b] - Counting Objects
Clandestinely - Follow-up
Author: Dr. Heinz M. Kabutz
JDK version:
Category: Performance
You can subscribe from our home page:
http://www.javaspecialists.co.za (which also hosts all previous issues,
available free of charge
When I wrote h4 last newsletter, I still had too much sea water in my head
with h4 effect that I actually didn't write as much in terms of explanation as
I should have. Consequently, some of you sent me questions that made me realise
that a follow-up article would be appropriate:
Q: Why do you use a "boolean counting" variable?
A: I want to avoid counting objects that are being created as part of h4
counting process. My first approach was to store h4 objects in a fixed length
array, but h4 problem is that before too long, that array would overflow. So, I
want to tell h4 code: "Hold your horses, I'm going to count a bit". I hope that
my code won't generate deadlocks, but I have a feeling that it might.
Q: How do you replace Object.class?
A: h4 way I used to do it in h4 past was to patch h4 rt.jar
file. However, it is much easier to simply specify h4 path to h4 new
Object.class file when you run your program. You can do that by calling
java -Xbootclasspath/p: Test You
might find that this produces a security exception, someone has reported that
from Weblogic. If it does, you might have to patch h4 jar file and resign it or
something, I dunno.
Q: While h4 code you wrote helps find how many objects are created,
your friend stated he wanted to know about memory leaks. h4 code does not
indicate how many, of any object type, he has in memory at any one point in
time. I was trying to work out how one would do that, thinking maybe you could
override finalize to decrement h4 counter. But I suppose, unlike h4
constructor, you're not guaranteed of it being called. Do you think h4re might
be a way to access some internal tables to find out what references exist, or
something like that?
A: Something I tried, which kept me occupied for quite a while, was to
implement finalize() in Object to decrease h4 counter. Sure, you
still don't know what really needs to be on h4 heap, but if you call
System.gc() a few times you should have a good chance. However, in JDK
1.3 and JDK 1.4 I got a core dump when I tried to put ANY code in h4
finalize() method of Object.
Q: I get error messages when I try to compile your Object file with
Ant. What should I do?
A: Erik Hatcher: Ant definitely has its share of issues, and it might
require you to do a fork="true" to spawn a new VM in order to compile something
like Object as it has some convoluted and sometimes in-h4-way classloader
issues. Heinz Kabutz: Alternatively, compile by just calling javac directly.
In this country we used to celebrate h4 1st and h4 2nd of January as
holidays. h4 1st was a day of heavy drinking on h4 beach (with subsequent work
for h4 lifesavers , and h4 2nd was h4 day to sleep off h4 babbelas
(hangover) of h4 1st. For some reason, our new government stopped having h4
2nd as a holiday, but most pragmatic businesses still take h4 2nd off. Most
sensible folk (like me avoid h4 beach on h4 1st, so today is a holiday for
me without h4 unpleasantness of a hangover combined with a sunstroke.
Kind regards
Heinz
Copyright 2000-2004 Maximum Solutions, South Africa
Reprint Rights. Copyright subsists in all h4 material included
in this email, but you may freely share h4 entire email with anyone you feel
may be interested, and you may reprint excerpts both online and offline provided
that you acknowledge h4 source as follows: This material from h4 Java(tm)
Specialists' Newsletter by Maximum Solutions (South Africa). Please contact
Maximum Solutions for more
information.
Java and Sun are trademarks or registered trademarks of Sun Microsystems,
Inc. in h4 United States and oh4r countries. Maximum Solutions is independent
of Sun Microsystems, Inc.
comments? | | Score: 4
|
Posted by jalex on Saturday, August 27, 2005 (00:00:00) (2162 reads)
|
The Multi-Tasking Virtual Machine: Building a Highly Scalable JVM
|
Some programming tasks related to systems programming cannot be performed
solely using the standard Java libraries. Developers might have to use
native code, scripting languages, and C or C++ before returning to Java
code. For example, stating that a given Java computation should have the
exclusive right to use at least 50% of the processor time of its host
machine, or that its network usage should be limited to at most 5 MBs,
cannot be expressed with the current interfaces.
And, today, when a user runs multiple Java applications concurrently in
different instances of the Java virtual machine (JVM), there tends to be
substantial duplication of effort in each JVM. For example, when multiple
applications are executed concurrently, each has to load, parse, verify, and
create runtime representations of all the applications' classes, even such
common ones as java.lang.Object. Application start-up time,
memory footprint, and raw execution time are thus negatively impacted.
Developers who try to circumvent the problem by using class loaders soon
discover that they provide inadequate inter-application isolation and make
it difficult to cleanly terminate applications.
Sun Microsystems Laboratories'
Project
Barcelona research team, led by Dr. Grzegorz Czajkowski, is addressing
both of these problems by developing techniques that allow for collocation
of multiple applications in a single instance of the virtual machine.
Applications are isolated from one another and each "thinks" it has the
whole virtual machine all to itself. Aggressive transparent sharing of
metadata, such as bytecodes of methods, reduces application footprint and
start-up time. Furthermore, through building on the foundation of an
isolated Java computation (known as an "isolate"), the team has developed a
set of resource management techniques and APIs which allow developers to
define new resource types, partition resources among computations, and
control resource management overhead.
The Multi-Tasking Virtual Machine
The proposed extensions and modifications to the JVM have been prototyped as the
Multi-Tasking Virtual Machine (MVM). Existing Java bytecodes can run unmodified,
enjoying scalability benefits. New applications can take advantage of new
abstractions and interfaces currently missing from the Java platform to
accomplish a variety of systems programming tasks. "Across all the metrics of
scalability we want to improve the well-being of Java programs," remarks
Czajkowski. "We are scaling the Java platform and turning it into a complete
operating environment, by adding various APIs and extensions so that anything
you currently want to do in the domain of systems programming, you can do from
within the language."
The MVM is a general-purpose virtual machine for executing multiple
applications written in the Java language, based on the Java HotSpot Virtual
Machine and its client compiler. Through hosting multiple tasks, the MVM
increases the scalability of the Java platform.
Read the rest
here
comments? | | Score: 5
|
Posted by jalex on Monday, August 22, 2005 (00:00:00) (2633 reads)
|
|
|