Results 21 to 32 of 32
Thread: Java optimization
- 02-17-2010, 01:35 PM #21
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
- 02-17-2010, 02:02 PM #22
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Why is what?
Could you please phrase a full and detailed question, because I am now lost as to what you're asking about.
- 02-17-2010, 02:06 PM #23
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Oh <pause> My <pause> God! Not Again!
See this
Edit: You have no idea what you're doing and are in completely over your head. You got some game from somewhere that doesn't run quite how you'd like it to, if at all, and you're looking for some "silver bullet" solution to turn it into a "workhorse". Well, here's your solution, get a computer with about 64 3 GHz Quad-4 CPU's with hardware threads, and about 100 Gb memory. Then start the server with "-server -d64 -Xms25000m -Xmx100000m".Last edited by masijade; 02-17-2010 at 02:16 PM.
- 02-17-2010, 02:06 PM #24
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
Basically how to make the source codes more faster like uses lesser RAM?
- 02-17-2010, 02:16 PM #25
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Blimey.
I forgot about that thread.
Look, Raymond...there is no "go faster" magic to Java. You need to go through your code and figure out where it's going wrong...or slow...or whatever requirement you have that it's failing to do.
So, please...stop posting these sorts of questions because there is no answer!
- 02-17-2010, 02:19 PM #26
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
I think I get deadlocks here:
public static MapleStorage loadOrCreateFromDB(int id) {
MapleStorage ret = null;
int storeId;
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM storages WHERE accountid = ?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
if (!rs.next()) {
rs.close();
ps.close();
return create(id);
} else {
storeId = rs.getInt("storageid");
ret = new MapleStorage(storeId, (byte) rs.getInt("slots"), rs.getInt("meso"));
rs.close();
ps.close();
String sql = "SELECT * FROM inventoryitems " + "LEFT JOIN inventoryequipment USING (inventoryitemid) " + "WHERE storageid = ?";
ps = con.prepareStatement(sql);
ps.setInt(1, storeId);
rs = ps.executeQuery();
while (rs.next()) {
MapleInventoryType type = MapleInventoryType.getByType((byte) rs.getInt("inventorytype"));
if (type.equals(MapleInventoryType.EQUIP) || type.equals(MapleInventoryType.EQUIPPED)) {
int itemid = rs.getInt("itemid");
Equip equip = new Equip(itemid, (byte) rs.getInt("position"), rs.getInt("ringid"));
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) rs.getInt("quantity"));
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
ret.items.add(equip);
} else {
Item item = new Item(rs.getInt("itemid"), (byte) rs.getInt("position"), (short) rs.getInt("quantity"), rs.getInt("petid"));
item.setOwner(rs.getString("owner"));
ret.items.add(item);
}
}
rs.close();
ps.close();
}
} catch (SQLException ex) {
log.error("Error loading storage", ex);
}
return ret;
}
- 02-17-2010, 02:23 PM #27
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
<Knock><Knock><Knock>Hello! <pause> Is there anybody home!? <pause> (thinks to self as leaving) well, the lights are on, but there doesn't seem to be anybody home.
P.S. This is a perfect case-in-point. There is absolutely no synchronization involved there, so why, in the heck, do you think that there even might be a deadlock issue there? Just thought I'd illuminate that fact, and this point, and I will leave it at that, now.Last edited by masijade; 02-17-2010 at 02:26 PM.
- 02-17-2010, 02:25 PM #28
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
You "think"?
You can't mistake a deadlock because...well...it deadlocks.
And you really need to format your code.
- 02-17-2010, 02:28 PM #29
Member
- Join Date
- Jan 2010
- Posts
- 32
- Rep Power
- 0
Everytime it loads or create my server crashes. I wonder why ;)
- 02-17-2010, 02:30 PM #30
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
- 02-17-2010, 02:38 PM #31
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,381
- Blog Entries
- 7
- Rep Power
- 17
Bitrot, it's definitely bitrot; does your server smell like fungi? If so, it's bitrot.
kind regards,
Jos ;-)
- 02-17-2010, 02:40 PM #32
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
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