Results 1 to 20 of 32
Thread: Java optimization
- 02-16-2010, 01:55 AM #1
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
- 02-16-2010, 05:24 AM #2
Using a profiler usually helps. Netbeans, for example, has a profiler plugin that can be used to look for bottlenecks in CPU usage and memory. You can even select a small subset of classes that you are interested in.
As far as caching... that is a good idea to do when you can.
"Dont gc." Umm... leave the garbage collection alone.
"Synchronization" that has nothing to do with efficiency.
"XMX" nothing wrong with this.My Hobby Project: LegacyClone
- 02-16-2010, 10:38 AM #3
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
I heard its not a proper way to allocate memory, its like forcing RAM when windows cannot take."XMX" nothing wrong with this.
- 02-16-2010, 10:42 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
Are you talking the xMx switch for the JRE?
- 02-16-2010, 10:57 AM #5
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
I think so, basically its a game server and on the channel.bat it has XMX - .
I heard its a bad way of allocating memory.
- 02-16-2010, 11:06 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
If you're talking about xMx (ala java -xMx512M) then I have no idea where you get the idea about memory allocation. It merely informs the JRE "this is the maximum memory you can have"...and without it it uses some rather small default value that's usually insufficient.
I find it hard to believe someone would say that that switch is a bad thing...
- 02-16-2010, 12:06 PM #7
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
I heard also only if you get memory leaks you use XMX.
- 02-16-2010, 12:19 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
I do honestly wonder if we're talking about the same thing.
Especially since you capitalise it.
I have not worked on a web project that did not require xMx to be set to something other than the default because, otherwise, there would be an OutOfMemory error.
- 02-16-2010, 12:31 PM #9
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
Here you will see what I mean : XiuzSource - Revision 23: / look at the .bat files. You will get what I mean.
- 02-16-2010, 12:39 PM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
Can't you just post the relevant bits here?
Not that I'm paranoid or anything...:)
- 02-16-2010, 12:46 PM #11
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
Sure,
There thats the part.@echo off
color b
@title XiuzSource: Channel
set CLASSPATH=.;dist\xiuzsource.jar;dist\mina-core.jar;dist\slf4j-api.jar;dist\slf4j-jdk14.jar;dist\mysql-connector-java-bin.jar
java -Xmx600m -Dnet.sf.odinms.recvops=recvops.properties -Dnet.sf.odinms.sendops=sendops.properties -Dnet.sf.odinms.wzpath=wz\ -Dnet.sf.odinms.channel.config=channel.properties -Djavax.net.ssl.keyStore=filename.keystore -Djavax.net.ssl.keyStorePassword=passwd -Djavax.net.ssl.trustStore=filename.keystore -Djavax.net.ssl.trustStorePassword=passwd net.sf.odinms.net.channel.ChannelServer -Dcom.sun.management.jmxremote.port=13373 -Dcom.sun.management.jmxremote.password.file=jmxrem ote.password -Dcom.sun.management.jmxremote.access.file=jmxremot e.access
pause
- 02-16-2010, 12:52 PM #12
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
Which is setting the max memory that the JVM can use to 600m.
At least we're talking about the same thing...:)
There is nothing wrong with that.
I don't see why anyone would think that's a bad thing, performance-wise.
- 02-16-2010, 01:13 PM #13
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
How to properly allocate memory for a game server?
- 02-16-2010, 01:23 PM #14
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
How long is a piece of string?
- 02-16-2010, 04:17 PM #15
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
I dont understand you o.o
- 02-16-2010, 04:27 PM #16
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
You asked a question we had no hope of actually answering.
That's assuming your question was how much memory should you allocate to the server via Xmx...
We don't know your server, what it does, what load is expected...anything in fact.
- 02-16-2010, 06:16 PM #17
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
It's an MMO and runs over 100+ online. RAM: 1.90-2.18GB CPU: 1-10%
Thats the info. I allocate XMX 2450. It uses MYSQL each time someone logs of or logs in and saves items.
- 02-17-2010, 09:07 AM #18
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
No, you don't understand.
We simply cannot size your JVM for you.
You have to run load tests based on your assumptions about what the likely load on it will be, and then see what the memory usage looks like.
We cannot do that.
- 02-17-2010, 11:35 AM #19
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
What do you mean troll? I want to improve on the codings.
- 02-17-2010, 11:50 AM #20
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
There isn't an 'r' in the name...
And sizing a JVM is not something we can do.
You've given it 2.5G (possibly), which is more than your available RAM. I can tell you that is not a good thing, since the JVM will eventually end up having to page memory. The most you can probably give is about 1G, to ensure you have enough space for OS stuff as well. But that doesn't mean you should give it that much. Which takes me back to you needing to do the legwork to figure out how big your JVM needs to be.
If you have some other question then by all means ask that one, but the memory requirements of you app isn't one we can deal with here.
Similar Threads
-
Circuit optimization
By MIA6 in forum New To JavaReplies: 1Last Post: 10-18-2009, 02:14 AM -
Optimization of code
By new_coder in forum New To JavaReplies: 1Last Post: 08-16-2009, 09:38 PM -
Query Optimization
By gilbertsavier in forum JDBCReplies: 0Last Post: 08-05-2009, 10:36 AM -
toHexString optimization (in fact general optimization question)
By jann in forum Advanced JavaReplies: 7Last Post: 12-16-2008, 06:44 PM -
java code optimization
By hey in forum New To JavaReplies: 0Last Post: 02-10-2008, 05:16 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks