Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7883459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:32:15+00:00 2026-06-03T04:32:15+00:00

I am running below code via eclipse in windows and then in Unix as

  • 0

I am running below code via eclipse in windows and then in Unix as standalone java.

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.sql.SQLException;
import java.text.ParseException;

public class readObjectBoeing {



/**
 * @param args
 * @throws ParseException 
 * @throws SQLException 
 */
public static void main(String[] args) {
    //File file = new File("/opt/app/d1ebp1m1/dv01/Vibhor/test/00017741_repository.dat");
    File file = new File("C:/_Vibhor/00017741_repository.dat");
    InputStream is;
    try {
        is = new FileInputStream(file);
        byte[] b = toByteArray(is);//read from file;
        Object o1 =null;
        o1 = convertByteArrayToObject(b);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
public static Object convertByteArrayToObject(byte[] buf) throws Exception 
{

    if (buf.length == 0)
    {
        return null;
    }
    long startTime = -1;
    long step1=-1,step2=-1;
    Object                  obj = null;
    ByteArrayInputStream    bis = null;
    ObjectInputStream       in  = null;
    try 
    {   
        bis = new ByteArrayInputStream(buf);
        in  = new ObjectInputStream(bis);
        startTime = System.currentTimeMillis()/1000;
        obj = in.readObject();
        step1 = System.currentTimeMillis()/1000 - startTime ;
        System.out.println("in.readObject()!! :  " + step1);
    } 
    catch (Exception e) 
    {
        throw e;
    } 
    finally 
    {
        if (in != null) 
        {
            in.close();
        }
        if (bis != null) 
        {
            bis.close();
        }
        in  = null;
        bis = null;
    }

    return obj;
}
public static byte[] toByteArray(InputStream input) throws IOException
{
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    long count = 0L;
    byte[] buffer =new byte[4096];
    for(int n = 0; -1 != (n = input.read(buffer));){
        output.write(buffer, 0, n);
        count += n;
    }
    return output.toByteArray();
}

}

00017741_repository.dat – it is 57Mb file.
In windows obj = in.readObject();– it takes me 4-5 seconds.
But in Unix obj = in.readObject(); it takes me 19 – 25 sec!

I am using VM args -Xmx512m to execute in both cases.

In unix:

java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) Server VM (build 20.4-b02, mixed mode)

In Windows:

jre 1.6.0_26

What am I missing here? Any suggestions to improve the performance in unix?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:32:17+00:00Added an answer on June 3, 2026 at 4:32 am

    Here are two specific things you can do to figure this one out:

    1. make sure that on Unix the file resides on a local file system and not on a network mount;
    2. use a profiler (such as YourKit) to find out where the time is spent.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Running the below code with Fiddler shows that plus signs are getting converted to
When running the below code a type is never returned, despite there being a
I am getting an argument of length zero after running the code below. I
I wanted to generate a list view using below code. But after running this
Hello friends i am running code given below which contains the setLogTimeEntery function and
While running the code I've included below I receive the error EntityCommandExecutionException was unhandled
I have a Windows Service that does the following when started. When running via
I am running groovy by embedding it in a Java application via the following
I am running the query below in Sybase application which works great but the
I receive the error below when running the following function. The catch says the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.