Excelsior Forums

# Application hangs during file I/O

## Recommended Posts

My compiled application hangs (GUI non-responsive) for about 30 seconds when I try to save a 1MB file to a floppy disk. Once the disk operation is done, the appllication becomes responsive again. I tried the exact same scenario in the non-compiled (interpreted) version of my application and GUI is still responsive to user input.

I am currently using JET 3.7 with Maintenance Pack 4. Here are the options I am using to run the applicaiton: "-Djet.gc.heaplimit:296m -Djet.gc.ratio:30 -Djet.gc.defragment -Djet.gc.dont.optimize.finalization"

I was wondering whether anyone faced similar issues during large file I/O. Any suggestions?

##### Share on other sites

It is strange occurence: I have wrote the next example and it works:

=====

import javax.swing.*;? ?

import java.awt.*;

import java.awt.event.*;

import java.io.*;

public class HelloSwing {

? ? public static void main(String[] args) {

? ? ? ? JFrame frame = new JFrame("HelloSwing");

? ? ? ? frame.setSize (350, 350);

? ? ? ? JLabel l = new JLabel("Hello, Swing!", JLabel.CENTER);

? ? ? ? Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();

? ? ? ? int x = (scrDim.width - frame.getSize().width) /2;

? ? ? ? int y = (scrDim.height - frame.getSize().height) /2;

? ? ? ? frame.setLocation(x, y);

? ? ? ? ? ? public void windowClosing(WindowEvent e) {

? ? ? ? ? ? ? ? System.exit(0);

? ? ? ? ? ? }

? ? ? ? });

? ? ? ? frame.setVisible(true);

? ? ? ? try {

? ? ? ? ? ? OutputStream out = new FileOutputStream ("a:\\zzz");

? ? ? ? ? ? byte arr[] = new byte[1024*1024];

? ? ? ? ? ? out.write(arr);

? ? ? ? ? ? out.close();

? ? ? ? ? ? l.setText("Done");

? ? ? ? } catch (Exception e) {

? ? ? ? ? ? e.printStackTrace();

? ? ? ? }

? ? }

}

=====

Could you please write a little example to reproduce this problem?

*FSA

## Create an account

Register a new account