lundi 23 novembre 2015

Rasberry-pi is taking more memory compare to Windows

I created a class which contains only SQL Lite connection's code in java . So here I executed this program in Linux(raspberry-pi) & windows than I observe Linux is taking more memory in comparison of windows

The memory shown below for Linux

  PID USER      PR  NI  VIRT  RES   SHR S  %CPU %MEM    TIME+   COMMAND 
 3337 root      20   0  744m  179m  10m S   0.0 19.4    0:07.79 dbtest.java 

Windows take 18 mb with Connection Code

& here if I comment the Connection's code then it takes less memory

  PID USER      PR  NI  VIRT  RES   SHR S  %CPU %MEM    TIME+   COMMAND 
 3337 root      20   0  596m  17m  10m S   0.0 19.4    0:07.79 dbtest.java 

Windows take 9 mb without Connection Code

I wanna know why Linux is taking quiet memory, if anyone know please look my problem.

package test;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBTest {

    public static void main(String[] args) {
        dbtest();
        while (true) {
            try {
                Thread.sleep(20000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }   
    }

    public static boolean dbtest() {
        Connection conn = null;
        try {

            System.out.println("Before ...... Class.forname");
            Class.forName("org.sqlite.JDBC");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {

                e.printStackTrace();
            }
            String dbURL = "jdbc:sqlite:product.db";
            conn = DriverManager.getConnection(dbURL);
            if (conn != null) {
                System.out.println("Connected to the database");
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {

                    e.printStackTrace();
                }
                DatabaseMetaData dm = (DatabaseMetaData) conn.getMetaData();
                System.out.println("Driver name: " + dm.getDriverName());
                System.out.println("Driver version: " + dm.getDriverVersion());
                System.out.println("Product name: "
                        + dm.getDatabaseProductName());
                System.out.println("Product version: "
                        + dm.getDatabaseProductVersion());
                conn.close();
            }
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        } catch (SQLException ex) {
            ex.printStackTrace();
        } finally {
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return false;
    }  
}

Aucun commentaire:

Enregistrer un commentaire