Results 1 to 3 of 3
  1. #1
    newbie14 is offline Member
    Join Date
    Feb 2010
    Posts
    63
    Rep Power
    0

    Default Java total memory and memory usage increase when using mysql function?

    We have a snippet of codes which does a select based on the mysql defined function.We have caught that once this portion is enabled then runtime.totalMemory() and used memory keep increasing. Below is the snippet of codes. The problem starts from String selectQuery4. I have tried this for debugging usr/java/jdk1.7.0_03/bin/jstat -gcutil 7525. I notice there is a change in the S0 and S1 values. Any idea what is this the problem with the increase?

    Java Code:
    double currentLong = Double.parseDouble(longitude);
    double currentLat = Double.parseDouble(latitude); 
     
    Statement stmt6 = null;
    stmt6 = dbconn.createStatement(); 
     
    String selectQuery3 = "Select geoFenceID,enterpriseID,clientID,geoFenceString,geoFenceType,geoFenceName,geoFenceDescription,geoFencePreference, geoFenceRadius From tblGeoFence Where ((enterpriseID="+enterpriseID+" And clientID=0) Or (enterpriseID="+enterpriseID+" And clientID="+clientID+")) And geoFenceStatus='a'"; 
    ResultSet rs3 = stmt6.executeQuery(selectQuery3);
     
    while(rs3.next()) {
        geoFenceID = rs3.getInt("geoFenceID");
        geoFenceType = rs3.getString("geoFenceType");
        geoFenceString = rs3.getString("geoFenceString");
        geoFenceRadius = rs3.getInt("geoFenceRadius");
        geoFencePreference = rs3.getString("geoFencePreference");
        String polygon  =  "GeomFromText('"+geoFenceString+"')";
        String point    =  "GeomFromText('POINT("+currentLong+"  "+currentLat+")')";
     
        Statement stmt7 = null;
        stmt7 = dbconn.createStatement();
        String selectQuery4 = "SELECT GISWithin("+point+","+polygon+") As geoFenceStatus";
        ResultSet rs4 = stmt7.executeQuery(selectQuery4);
     
        if(rs4.next()) {
     
            if(rs4.getInt("geoFenceStatus")==1) {
     
                geoFenceIDFound=geoFenceID;
                geoFenceName = rs3.getString("geoFenceName");
                geoFenceDescription = rs3.getString("geoFenceDescription");                                                     
                geoFencePreference = rs3.getString("geoFencePreference");   
     
                if(lastGeoFenceID==geoFenceID) {
                    geoFenceInID = geoFenceID;                  
                    break;
                } else {
     
                    if(previousGeoFenceID==geoFenceID &&(previousTimeDifferenceInt<0 || geoFenceArriveTimeDifferenceInt <= 0)) //check the funny problem double entry back into the geo fence
                    {
                        lastGeoFenceID=geoFenceID;
                        geoFenceInID = geoFenceID;
                        break;
                    } else {
                        geoFenceAlertEmailMessage="\nGeo Fence Alert Arrival\nTime:"+dateTimer+"\nGeo Fence Name :"+geoFenceName+"\nGeo Fence Description :"+geoFenceDescription+"\nGeo Fence Preference:"+geoFencePreference;
     
                        if(lastGeoFenceEntryStatus.equals("") || lastGeoFenceEntryStatus.equals("Out")) {
                            geoFenceEntryStatus="In";
                        } else {
                            geoFenceEntryStatus="Out";
                        }
                    }
                }
            }
        }
    }
     
    try {
        if ( rs4 != null ) {
            rs4.close();
        }                                        
        if ( stmt7!= null ) {
            stmt7.close();
        }
    } catch(SQLException ex) {
        ex.printStackTrace(System.out);
    }             
    }           
    try {
        if ( rs3 != null ) {
            rs3.close();
        }                              
        if ( stmt6!= null ){
            stmt6.close();
        }                              
    } catch(SQLException ex) {
        ex.printStackTrace(System.out);
    }
    Codes used to print the memory stats.

    Java Code:
    int mb = 1024*1024;
    System.out.println("##### Heap utilization statistics [MB] #####");
     
    //Print used memory
    System.out.println("Used Memory:" + (runtime.totalMemory() - runtime.freeMemory()) / mb);
     
    //Print free memory
    System.out.println("Free Memory:" + runtime.freeMemory() / mb);
     
    //Print total available memory
    System.out.println("Total Memory:" + runtime.totalMemory() / mb);
     
    //Print Maximum available memory
    System.out.println("Max Memory:" + runtime.maxMemory() / mb);

  2. #2
    sabre150 is offline Member
    Join Date
    Jul 2012
    Location
    Earth
    Posts
    75
    Rep Power
    0

    Default Re: Java total memory and memory usage increase when using mysql function?

    So you think that you might get a different reply from that at https://forums.oracle.com/forums/thr...29143&tstart=0 .

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

Similar Threads

  1. How do I increase java memory in windows 7?
    By Masherbrum in forum New To Java
    Replies: 13
    Last Post: 03-07-2012, 05:56 PM
  2. How to increase Memory to java runtime process
    By gianpiero.guerrera82 in forum Advanced Java
    Replies: 0
    Last Post: 10-31-2011, 10:37 AM
  3. runing Java program increases continuing memory usage
    By henry123 in forum Advanced Java
    Replies: 12
    Last Post: 02-25-2011, 02:09 PM
  4. Replies: 2
    Last Post: 08-21-2008, 07:33 PM
  5. JVM memory usage
    By lardum in forum New To Java
    Replies: 7
    Last Post: 06-26-2008, 03:30 AM

Posting Permissions

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