Page 2 of 2 FirstFirst 12
Results 21 to 32 of 32
  1. #21
    Raymond is offline Member
    Join Date
    Jan 2010
    Posts
    32
    Rep Power
    0

  2. #22
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,854
    Rep Power
    19

    Default

    Why is what?
    Could you please phrase a full and detailed question, because I am now lost as to what you're asking about.

  3. #23
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    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.

  4. #24
    Raymond is offline Member
    Join Date
    Jan 2010
    Posts
    32
    Rep Power
    0

    Default

    Basically how to make the source codes more faster like uses lesser RAM?

  5. #25
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,854
    Rep Power
    19

    Default

    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!

  6. #26
    Raymond is offline Member
    Join Date
    Jan 2010
    Posts
    32
    Rep Power
    0

    Default

    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;
    }

  7. #27
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    <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.

  8. #28
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,854
    Rep Power
    19

    Default

    You "think"?
    You can't mistake a deadlock because...well...it deadlocks.

    And you really need to format your code.

  9. #29
    Raymond is offline Member
    Join Date
    Jan 2010
    Posts
    32
    Rep Power
    0

    Default

    Everytime it loads or create my server crashes. I wonder why ;)

  10. #30
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by Raymond View Post
    Everytime it loads or create my server crashes. I wonder why ;)
    Let me get this straight, so you think the method called "loadOrCreateFromDB" is what "loads or creates your Server"?

    We need go no further than this.

  11. #31
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,371
    Blog Entries
    7
    Rep Power
    20

    Default

    Bitrot, it's definitely bitrot; does your server smell like fungi? If so, it's bitrot.

    kind regards,

    Jos ;-)

  12. #32
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Java Code:
    while(true) { 
        headDesk++;
        faceDesk++;
    }
    is an example of code that will crash several things.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Circuit optimization
    By MIA6 in forum New To Java
    Replies: 1
    Last Post: 10-18-2009, 02:14 AM
  2. Optimization of code
    By new_coder in forum New To Java
    Replies: 1
    Last Post: 08-16-2009, 09:38 PM
  3. Query Optimization
    By gilbertsavier in forum JDBC
    Replies: 0
    Last Post: 08-05-2009, 10:36 AM
  4. Replies: 7
    Last Post: 12-16-2008, 06:44 PM
  5. java code optimization
    By hey in forum New To Java
    Replies: 0
    Last Post: 02-10-2008, 05:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •