vm optimizations
From: Murat Tasan (tasan_at_eecs.cwru.edu)
Date: 10/30/03
- Next message: Robert Sullivan: "Java heap size vs. OS memory"
- Previous message: sumithradevi_at_hotmail.com: "java.sql.SQLException: ORA-00020: maximum number of processes (100) exceeded"
- Next in thread: Saager: "Re: vm optimizations"
- Reply: Saager: "Re: vm optimizations"
- Reply: Raymond DeCampo: "Re: vm optimizations"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 29 Oct 2003 22:46:04 -0500
i asked something about java optimization before, but i gave a very poor
example... leading to not much help... so here is a better situation.
i have a Map, and i'm constantly picking entries from random from this
map.
in one method, i only use the map.
in another method, i use an array of keys from the map, stored seperately.
method a (only the map):
Map myMap = //initialize map
Object randObj;
// begin loop
randObj = myMap.keySet().toArray()[(int)Math.floor(Math.random() *
myMap.size())];
so, as you can see, in method a i constantly re-acquire the array of
keys... but reduce the clutter.
method b:
Map myMap = //initialize map
Object[] keyArray = myMap.keySet().toArray();
// begin loop
randObj = myMap.get(keyArray[(int)Math.floor(Math.random() *
keyArray.length)]);
the only change then is one single array that has a name.
what i'm wondering is:
does the compiler or runtime environment do any optimizations such that
method a is the same (or better maybe) than method b?
while i know the call stack will be one shorter in method b, i'm really
curious about whether or not method a constantly allocates and frees up
memory for the array.
does anyone know where i can find out about these sorts of issues, or can
anyone clear this example out for me?
thanks much,
murat
-- Murat Tasan mxt6@po.cwru.edu tasan@eecs.cwru.edu murat.tasan@cwru.edu http://genomics.cwru.edu
- Next message: Robert Sullivan: "Java heap size vs. OS memory"
- Previous message: sumithradevi_at_hotmail.com: "java.sql.SQLException: ORA-00020: maximum number of processes (100) exceeded"
- Next in thread: Saager: "Re: vm optimizations"
- Reply: Saager: "Re: vm optimizations"
- Reply: Raymond DeCampo: "Re: vm optimizations"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|