Solved

Large JVM memory size.

Posted on 2004-10-14
7
1,066 Views
Last Modified: 2008-02-01
The application that we are working on requires very fast response times and we are thinking of implementing some caching mechanisms using singleton.

The scary thing is that cache size may be quite large -- approximately 500MB - 1GB.

Question that I have consists of two issues:

1) How JVM would handle such large amount of memory dedicated to it ? Is there any limitations on memory size ?
2) In terms of the speed, shall we expect any performance degradation when JVM deals with such large objects ?

Thank you for your help.
0
Comment
Question by:sasha_kv
7 Comments
 
LVL 8

Expert Comment

by:kiranhk
Comment Utility

1) How JVM would handle such large amount of memory dedicated to it ? Is there any limitations on memory size ?
You can increase the memory size for the JVM using the following
java -Xms256m -Xmx512m


2) In terms of the speed, shall we expect any performance degradation when JVM deals with such large objects ?
If indeed you have so much of data cache the performance really depends on how you actually use the cache. Basically like you might be loading the whole data into memory and for navigating to the required data from the clients perspective depends on how u program to retrieve the data.
0
 

Author Comment

by:sasha_kv
Comment Utility
1) I am familiar how to  increase memory size for JVM. The question here is more conceptual on limitations of memory size.

I've found this quote on the internet and not sure about validity of the this statement:

-- On 32-bit processor machines, the largest contiguous memory address space the operating system can allocate to a process is 1.8GB. Because of this, the maximum heap size can only be set up to 1.8GB. On 64-bit processor machines, the 1.8 GB limit does not apply, as 64-bit processor machines have a larger memory address space."
--

2) Cache mechanism will be implemented using HashMap, where userID (int) would represent a key, and UserVO that contains all the necessary data about a user would represent a value. If desiralized version of UserVO takes up let's say 10kb, then caching 50,000 users would require 500mb of memory. (if my math is correct :)

0
 
LVL 14

Assisted Solution

by:Tommy Braas
Tommy Braas earned 150 total points
Comment Utility
Hi sasha_kv,

As far as limits on heap memory allocation. It really (apart from obvious 'physical' address space constraints) depends largely on the JVM implementation. I don't see a problem with a 500 MB of cache. We have caches here which exceed that amount. As far as performance goes, you might see a decrease in performance if you have a lot of objects with the same hash code, which is to be expected with a container type such as a hash table. How are you guarding access to the cache?

Cheers!

\tt
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 24

Accepted Solution

by:
sciuriware earned 150 total points
Comment Utility
I run a banking application to a limit of 1540 Mb; using the SUN JRE 1.4.2_03 there seemed to be a limit there.
I used very high quantities of small objects.
To my surprise the CPU usage was very low, so the garbage collector had no problems.
The application run repeatedly for 90 hours.
So, there isn't really a problem with major JRE's.
Only two advises:
1) monitor your memory usage (I put it in the aboutbox so everybody could inspect it),
2) keep off calling .gc() it does more harm than good.
;JOOP!
0
 
LVL 21

Assisted Solution

by:MogalManic
MogalManic earned 150 total points
Comment Utility
Look into using the LinkedHashMap.  It combines a linked list with the hashmap where the linked list is the Least Recently Used element.  This allows you to set a maxsize of your cache and to remove the oldest item in the cache.

You HAVE to set a maxsize of your cache (even if you never reach it).   You will probably NEVER reach the 1.8G maximum imposed by Windows.  When allocated memory starts approching the size of the REAL memory, the OS task scheduler will start thrashing (spending more time swaping memory than executing tasks).  This will degrade performance significantly.

I have seen this happen on both Windows and Unix environments (though the unix handled a larger memory allocation before thrashing).
0
 

Author Comment

by:sasha_kv
Comment Utility
Thanks very much for everyone's input !!!
0
 
LVL 14

Expert Comment

by:Tommy Braas
Comment Utility
=-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
java set up 1 46
base64 decode encode 12 96
solarwind tftp server 2 30
Java / Linux and Regular Expressions 11 43
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now