Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fill Queue with Files! 2

Status
Not open for further replies.

FOR111

Programmer
Sep 29, 2005
103
MT
Hi all,

I'm very new to Java and i need a small helping hand..just to get the ball rolling! I need to test the Garbage collection if its leaking memory, and they told me to create a simple queue of 1000, and fill them with a 100K file. Then loop endlesly pushing a new file and popping an old..and this should be recursive.

I'm using Java 1.506..just in case.

Thanks very much for any help! I would be much obliged for any help you could fork out!

Nick
 
Hi Dian

thanks for your reply.

It seems that our system is having some memory leak somewhere as memory is being consumed by the miniute, and they want to verify if its the Garbage collection that's at fault (since this version had a bug which was then solved in v1.508) or our system!

Thanks
Nick
 
Oh, sorry, I thought you were doing that as an exercise to learn Java, so it was just a joke.

I can offer you some more options:

1.- Do some profiling on the leaking machine, measuring the memory to test if it's really Java who is consuming memory. If so, use a profile monitor like JProbe to see which objects are consuming the memory.

2.- Update to 1.5 to test if the fix arranges the problem.

Anyway, if you tell us which is the bug, maybe we can offer any other sollution.

Cheers,
Dian

 
Hi again,

No though i'm actually learning java in the process..i'm more of a c++ developer though i'm still finding the syntax quite quirky hehe!

Thanks for the suggestion i will defintly put the JProbe suggestion forward to my collegue (now he is a Java guru hehe!)



Cheers
Nick
 
Just a small question:

What is the best way of creating a 100K dump temporary file?


Thanks
Nick
 
Something like

Code:
try {
        BufferedWriter out = new BufferedWriter(new FileWriter("outfilename"));
        for (int i=0;i<100000;i++)
           out.write("a");
        out.close();
    } catch (IOException e) {
    }

would do the job.

Cheers,
Dian
 
yeah i did that..though its very slow!

Thought there is a better way off!

Tahnks anyways!
Nick
 
well another way is :

Code:
byte[] data = new byte[100000];
for (int i = 0; i < data.length; i++) {
  data[i] = (byte)1;
}
FileOutputStream fos = new FileOutputStream("somefile.txt");
fos.write(data);
fos.flush();
fos.close();

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Forget about the buffer then

Code:
char[] buffer = new char[100000];
java.util.Arrays.fill(buffer,'a');
try {
        FileWriter fw = new FileWriter("outfilename"));
        fw.write(buffer);
        fw.close();
    } catch (IOException e) {
    }

Cheers,
Dian
 
Great..guys i thank you alot!

It got better now and its working great!

Cheers
Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top