• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Increase JVM size for thread creation

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 2 tasks in which I am using multithreading, in which one task is short task like login other is longer such as file transfer.

So is it there any way where I can provide small amount of jvm (thread) memory for small tasks and good amount of memory for large tasks.

For both tasks I have separate servers.

I have heard that we can increase size of java heap space .

Suppose I have a 2 GB memory RAM, So can I allocate 2 GB or 1.5 GB to my heap memory? I s it good way. What are positive and negative facts are there regarding it?

when and how should I use these JVM command line options -Xms and -Xmx for which kind of applications?


Any suggestions will be helpful.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pravin gate wrote:So is it there any way where I can provide small amount of jvm (thread) memory for small tasks and good amount of memory for large tasks.


You can certainly allocate more memory for a JVM (in several ways), but I'm not sure whether that include limits per Thread (never tried).

However, I'm not sure that either task you list is going to be affected much by throwing memory at it. As you say, the login task is small, and the file transfer task is likely to be limited by the speed of the connection rather than the amount of available memory. In fact, if it was me, I think I might be looking at limiting the amount of memory available to a file transfer process rather than expanding it, simply because it might be hanging around for a long time; however, I think I'd probably use a mechanism like a blocking queue to do it, rather than mucking about with startup params.

My advice would be to do profiling to find out
(a) Whether you really do have a problem, and
(b) Exactly where it is.

Winston
 
pravin gate
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok. So here I have created a Test application from which I am able to login(means creating connections to a singke port) number of users.
But after connecting 3000+ users , program giving me Outofflowmemory memory heap space exceptions.

I was trying to increase memory heap size like this way in java runtime settings :-Xms200m -Xmx500m.
But still I am not able to connect more users than 3000+users.

Why is it so? What should I need to do ?

Winston Gutkowski wrote:

pravin gate wrote:So is it there any way where I can provide small amount of jvm (thread) memory for small tasks and good amount of memory for large tasks.


You can certainly allocate more memory for a JVM (in several ways), but I'm not sure whether that include limits per Thread (never tried).

However, I'm not sure that either task you list is going to be affected much by throwing memory at it. As you say, the login task is small, and the file transfer task is likely to be limited by the speed of the connection rather than the amount of available memory. In fact, if it was me, I think I might be looking at limiting the amount of memory available to a file transfer process rather than expanding it, simply because it might be hanging around for a long time; however, I think I'd probably use a mechanism like a blocking queue to do it, rather than mucking about with startup params.

My advice would be to do profiling to find out
(a) Whether you really do have a problem, and
(b) Exactly where it is.

Winston

 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pravin gate wrote:ok. So here I have created a Test application from which I am able to login(means creating connections to a singke port) number of users.
But after connecting 3000+ users , program giving me Outofflowmemory memory heap space exceptions.


Are you sure this is a Java message, or are you, for example, logging in to a database?

I've seen references to 'flow memory' from the latter, but never from Java itself.

It would be a lot better if you include the entire message (or, indeed, the entire stack trace) exactly as you are getting it.

Winston
 
pravin gate
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This exception I am getting when I am trying to connect 4000 users to single port (means 4000 users will be logged in after successful login) .


And I am also printing Rutimefree memory of heap size which shows latest value 5328 before exception.
I am able to connect (login) around 3000 users without any exception.

So what should I need to do to login more users?

 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pravin gate wrote:This exception I am getting when I am trying to connect 4000 users to single port (means 4000 users will be logged in after successful login) .


Port, schmort - shouldn't make a whit of difference (except that you may be taxing a particular bit of inetd (or whatever the port listener du jour is these days)).

Also: nothing to do with 'flow memory'; or so it would seem.

The only thing I see is that there are an awful lot of what look like Swing or AWT methods involved. Any particular reason for that? It may be perfectly reasonable, but is it possible that you're retaining more than just the login credentials from your process?

Fraid I'm no expert when it comes to GUI apps, but 4,000 logins sounds pretty reasonable to me, even if they aren't doing anything. I've worked on some medium size servers that didn't allow that many user logins.

Apart from twiddling with the heap size, I can't suggest much more; if a 10% increase allows you 10% (or roundabout) more logins, I suspect you've found your bottleneck.

Winston
 
pravin gate
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok.Thanks Winston for your helpful suggestions.

I also tried to increase Jvm heap size (-Xms and -Xmx.) But It's not showing me any effects on output.I am still not able to login 4000 users.


Winston Gutkowski wrote:

pravin gate wrote:This exception I am getting when I am trying to connect 4000 users to single port (means 4000 users will be logged in after successful login) .


Port, schmort - shouldn't make a whit of difference (except that you may be taxing a particular bit of inetd (or whatever the port listener du jour is these days)).

Also: nothing to do with 'flow memory'; or so it would seem.

The only thing I see is that there are an awful lot of what look like Swing or AWT methods involved. Any particular reason for that? It may be perfectly reasonable, but is it possible that you're retaining more than just the login credentials from your process?

Fraid I'm no expert when it comes to GUI apps, but 4,000 logins sounds pretty reasonable to me, even if they aren't doing anything. I've worked on some medium size servers that didn't allow that many user logins.

Apart from twiddling with the heap size, I can't suggest much more; if a 10% increase allows you 10% (or roundabout) more logins, I suspect you've found your bottleneck.

Winston

 
Ranch Hand
Posts: 443
3
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a java option to dump -XX:+HeapDumpOnOutOfMemoryError set this on the command line , then when it crashes you get a hprof load that into Visual VM (with your JDK in bin directory) and it should tell you where your memory has gone or use EclipseMAT free download and look at the reports it generates.



 
Greenhorn
Posts: 17
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
-Xms and -Xmx willl be used to inistalise max memory pool and min memory pool.This can be used for any application.it is your chice how you application should behave by providing java options.

I would say keep the initial siz and max size to same value and try.So this way when jvm startsup it will have all the memory it need till the end.
There is no way you can give a thread based memory allocation in a single jvm(as far i know). you can try tlab opion but highly inefficiant if threads are not using the allocated memory (not running) good side of this is that you will have a chunk of memory only for the your thread running.
Maximum memory for you login application can be changed to 1024 if you want and see this has any effect.

But following also need to be checked.

1) memory leak-
closing connection .resultset and statemets after use preferably in finally if posible.
avoid declaring class level variables for evrything,
2) avoid keeping data into the memory.
3) need to identify where you hold chunks of data into memory?
4) try different gc mechanisms
I have no clue what effect awt windows have on you jvm interms of memory

Regards,
Rojan
reply
    Bookmark Topic Watch Topic
  • New Topic