When JVM spends %98 of it`s time to garbage collections and can not free more then %2 of the memory then an "Out of Memory" exception is thrown. Heap size (the memory space where the progam lives) is calculated according to physical memory. The initial heap size will be set to phys_mem / DefaultInitialRAMFraction. DefaultInitialRAMFraction is a command line option with a default value of 64. Similarly the maximum heap size will be set to phys_mem / DefaultMaxRAM. DefaultMaxRAMFraction has a default value of 4.
With my test machine 64 mb heap memory is not enough to hold as much images as I would like to. I increased memory size with this command line option;
-Xms64m -Xmx256m
This sets the initial and maximum size to 64mb and 256mb. The m suffix can be changed with g to represent gigabyte. You can find java 1.5 command line options here.
Although I set initial memory size to 64 mb, JVM doesn`t allocate 64 mb. When JVM starts it`s memory usage is increased slowly to 12 mb and then garbage collected to 1,5 mb and cycled. When I set initial memory to 4 mb it increased to 2 mb at startup then decreased to ~700 kb and cycled in a longer time period. If you are not sure that your application will use too much memory do not give a big initial memory value, JVM tries to increase memory size for nothing because gc cleans it.
Note: The Java object heap has to be allocated in contiguous virtual addresses, for implementation reasons. In 32 bit operating systems only 2gb memory can be addressed as contiguous.
Source: http://weblogs.java.net/blog/2005/04/28/jvm-memory-usage
Mar 3, 2011
JVM Heap
1. The OS always allocates contiguous memory space to the JVM
2. When there are more objects created & killed very frequently, the JVM stores them in memory spaces wherever they have free space.
3. This results in a situation called Heap Fragmentation ( same like disk fragmentation ) wherein the heap is fragmented.
4. This makes the JVM not to release the contiguous memory space to OS ( remember, memory is allocated /de-allocated in contiguous memory blocks)
How to Avoid Heap Fragmentation
1.Identify and reduce the frequent creation of unnecessary objects.
2.Compact the Heap by using the option -compactGc option of the JVM ( this comes with a performance penalty )
3. Keep the Max-Heap size setting to as close as possible to the maximum memory required by your JVM
2. When there are more objects created & killed very frequently, the JVM stores them in memory spaces wherever they have free space.
3. This results in a situation called Heap Fragmentation ( same like disk fragmentation ) wherein the heap is fragmented.
4. This makes the JVM not to release the contiguous memory space to OS ( remember, memory is allocated /de-allocated in contiguous memory blocks)
How to Avoid Heap Fragmentation
1.Identify and reduce the frequent creation of unnecessary objects.
2.Compact the Heap by using the option -compactGc option of the JVM ( this comes with a performance penalty )
3. Keep the Max-Heap size setting to as close as possible to the maximum memory required by your JVM
Jan 11, 2011
Jconsole
How to Launch JConsole to connect Weblogic MBeans?
1. Launch Jconsole using below command.
%JAVA_HOME%/bin/jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;%JAVA_HOME%\lib\tools.jar;%WLS_HOME%\server\lib\weblogic.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote (for Windows)
or
jconsole -J-Djava.class.path=$JAVA_HOME/lib/jconsole.jar:$JAVA_HOME/lib/tools.jar:$WLS_HOME/server/lib/weblogic.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote (for Linux)
2. Select Remote radio button on New Connection screen & Enter
service:jmx:t3://:/jndi/ weblogic.management.mbeanservers.runtime for Remote process text box
3. Press 'Connect' by providing Username & Password.
1. Launch Jconsole using below command.
%JAVA_HOME%/bin/jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;%JAVA_HOME%\lib\tools.jar;%WLS_HOME%\server\lib\weblogic.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote (for Windows)
or
jconsole -J-Djava.class.path=$JAVA_HOME/lib/jconsole.jar:$JAVA_HOME/lib/tools.jar:$WLS_HOME/server/lib/weblogic.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote (for Linux)
2. Select Remote radio button on New Connection screen & Enter
service:jmx:t3://
3. Press 'Connect' by providing Username & Password.
Dec 22, 2010
Dec 2, 2010
Nov 26, 2010
how to load properties from properties files?
Setting Up the Properties Object
The following Java code performs the first two steps described in the previous section: loading the default properties and loading the remembered properties:
. . .
/* create and load default properties */
Properties defaultProps = new Properties();
FileInputStream in = new FileInputStream("defaultProperties");
defaultProps.load(in);
in.close();
// create application properties with default
Properties applicationProps = new Properties(defaultProps);
// now load properties from last invocation
in = new FileInputStream("appProperties");
applicationProps.load(in);
in.close();
. . .
First, the application sets up a default Properties object. This object contains the set of properties to use if values are not explicitly set elsewhere. Then the load method reads the default values from a file on disk named defaultProperties.
Next, the application uses a different constructor to create a second Properties object, applicationProps, whose default values are contained in defaultProps. The defaults come into play when a property is being retrieved. If the property can't be found in applicationProps, then its default list is searched.
Finally, the code loads a set of properties into applicationProps from a file named appProperties. The properties in this file are those that were saved from the application the last time it was invoked, as explained in the next section.
Source:- http://download.oracle.com/javase/tutorial/essential/environment/properties.html
The following Java code performs the first two steps described in the previous section: loading the default properties and loading the remembered properties:
. . .
/* create and load default properties */
Properties defaultProps = new Properties();
FileInputStream in = new FileInputStream("defaultProperties");
defaultProps.load(in);
in.close();
// create application properties with default
Properties applicationProps = new Properties(defaultProps);
// now load properties from last invocation
in = new FileInputStream("appProperties");
applicationProps.load(in);
in.close();
. . .
First, the application sets up a default Properties object. This object contains the set of properties to use if values are not explicitly set elsewhere. Then the load method reads the default values from a file on disk named defaultProperties.
Next, the application uses a different constructor to create a second Properties object, applicationProps, whose default values are contained in defaultProps. The defaults come into play when a property is being retrieved. If the property can't be found in applicationProps, then its default list is searched.
Finally, the code loads a set of properties into applicationProps from a file named appProperties. The properties in this file are those that were saved from the application the last time it was invoked, as explained in the next section.
Source:- http://download.oracle.com/javase/tutorial/essential/environment/properties.html
Nov 23, 2010
sqlplus syntax
sqlplus sys/oracle@:/ as sysdba
eg:sqlplus sys/oracle@10.177.219.131:1521/orcl.idc.oracle.com as sysdba
eg:sqlplus sys/oracle@10.177.219.131:1521/orcl.idc.oracle.com as sysdba
Subscribe to:
Posts (Atom)
