-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.0
-
sparc
-
solaris_2.5
I am including a bug report that came in from a customer. I ran it,
and the Java interpreter crashed with an outOfMemory exception
after 10 minutes.
I ran it on Solaris with the following command:
java TraceTest
If you say
java TraceTest show
the problem is not observed.
I am not sure this is a Java issue or a X Windows issue. I will defer to
a higher authority.
BTW> I would like some feedback on this bug report. Should I have
put the program in a directory someplace or is it better to have
it here in the report itself.
Tom
-----------------------------------------------------
Tom-
Here is some information on an apparent bug in awt, in which (if a
target window is hidden), memory resources are consumed at an
alarming rate. Specifically, allocations of heap space are attempted
for obects of increasing size until heap extention occurs. Heap
extentions occur repeatedly until all virtual memory is consumed and
a crach occurs.
Please take a look at this and let me know what you find.
Thanks,
Ray
PS. We have worked around this problem, so it is not a show stopper
like the Solaris problem is (that I sent you the segmentation
problem on).
Thanks,
Ray
====================================================================
Attached are 2 files:
Trace.java (alias TRACE~1.JAV)
TraceTest.java (alias TRACET~2.JAV)
Trace is a simple class for 'debugging' output. It creates itself
on the fly and
appends a string to a TextArea. If the TextArea has more than 4k
of text in it,
Trace saves a timestamped file to disk (i.e. cattrace<millis>).
While Trace is visible, it works well. If Trace is hidden, memory
is consumed at
an alarming rate and NOT released.
TraceTest is a very short, simple test class for Trace. It feeds a
string
preceeded by an index number into Trace until it is stopped. If
there is
ANYTHING on the command line, Trace is shown. With no command
option,
Trace is hidden.
To observe these results, use the following commandline:
java verbosegc TraceTest [show]
Kevin Clougherty
FTP Software
(508) 684-6068
(508) 684-6038 FAX
====================================================================
/*
* @(#)Trace.java 0.90 12/5/95 Adam Doppelt
*/
/*
*
* Copyright (c) 1996 FTP Software, Inc. All rights reserved.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL or COMMERCIAL purposes
is expressly prohibited.
*
* FTP Software MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. YOUR COMPANY SHALL NOT
BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*
* THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS
ON-LINE
* CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
* PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES,
AIRCRAFT
* NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT
LIFE
* SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
* SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
* PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). FTP
Software
* SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS
FOR
* HIGH RISK ACTIVITIES.
*/
/*
*
* @version 0.90 5 Dec 1995
*
* Extensively modified by: KSC
* Date: 96/02/15
* Description:
*
* Usage Notes:
*
*
*/
import java.awt.*;
import java.io.*;
/**
* Trace can be used in place of System.out. It is basically a
* window into which text can be written. The text can also be saved
* to a file, or cleared.<P>
*
* The log will be automatically created the first time it is
used.<P>
*
*
*/
public class Trace {
// the size of the text area
final private static int ROWS = 25;
final private static int COLS = 80;
public static MenuItem menuSave = new MenuItem("Save...");
public static MenuItem menuClear = new MenuItem("Clear");
public static MenuItem menuHide = new MenuItem("Hide");
static TextArea area_ = null;
static private String fileName;
static TraceFrame f;
// Actually creates the window and text area. Should only be
// called once.
static void create() {
f = new TraceFrame("Trace");
area_ = new TextArea(ROWS, COLS);
area_.setEditable(true);
MenuBar menuBar = new MenuBar();
Menu menu = new Menu("&File");
menu.add(menuSave);
menu.add(menuClear);
menu.add(menuHide);
menuBar.add(menu);
f.setMenuBar(menuBar);
f.setLayout(new BorderLayout(5, 5));
f.add("Center", area_);
Dimension size = area_.preferredSize();
area_.resize(size);
size.width += 30;
size.height += 60;
f.resize(size);
}
static void show() {
if (area_ == null)
create();
f.show();
}
/**
* Writes a string to the log.
* @param s The string to write.
*/
static public synchronized void print(String s) {
if (area_ == null)
create();
if (area_.getSelectionEnd() >= 4000) {
save("cattrace" + System.currentTimeMillis());
clear();
}
area_.appendText(s);
}
/**
* Writes a string + newline to the log.
* @param s The string to write.
*/
static public synchronized void println(String s) {
print(s + "\\n");
}
/**
* Writes an empty line to the log.
*/
static public synchronized void println() {
print("\\n");
}
/**
* Writes an object to the log using the toString method
*/
static public synchronized void print(Object o) {
print(o.toString());
}
/**
* Writes an object to the log using the toString method followed by
a new line
*/
static public synchronized void println(Object o) {
print(o);
println();
}
/**
* Saves the log to a file. If saving fails for some reason, the
exception will be
* printed in the log.
*/
static public synchronized void save() {
if (area_ == null)
create();
PrintStream output = null;
if (fileName == null)
fileName = "trace.txt";
try {
output = new PrintStream(new FileOutputStream(fileName));
}
catch (Exception e) {
println();
println("Error: could not save trace to \\"" + fileName + "\\".");
println("Exception: " + e);
return;
}
output.println(area_.getText());
output.close();
}
/**
* @param filename The file to save to. */
static public void save(String newFileName) {
if (newFileName != null)
fileName = newFileName;
save();
}
/**
* Clears the log.
*/
static public synchronized void clear() {
if (area_ == null)
create();
area_.setText("");
}
static public boolean handleEvent(Event e) {
if (e.target == menuClear) {
clear();
return true;
}
if (e.target == menuSave) {
FileDialog fd = new FileDialog(f, "Trace save",
FileDialog.SAVE);
fd.show();
fileName = fd.getFile();
if (fileName != null) {
save(fileName);
}
return true;
}
if (e.target == menuHide) {
f.hide();
}
return false;
}
}
class TraceFrame extends Frame implements FilenameFilter {
public TraceFrame(String title) {
super(title);
String currentDir = System.getProperty("user.dir");
File oldTraces = new File(currentDir);
oldTraces.list(this);
}
public boolean accept(File dir, String fileName) {
if (fileName.startsWith("cattrace")) {
File traceFile = new File(dir, fileName);
traceFile.delete();
}
return false;
}
public boolean handleEvent(Event e) {
int oldCursor = getCursorType();
setCursor(WAIT_CURSOR);
boolean returnVal = Trace.handleEvent(e);
setCursor(oldCursor);
return returnVal;
}
}
===================================================================
class TraceTest {
public static void main(String args[]) {
Trace.println("Trace Test");
if (args.length > 0)
Trace.show();
int index = 0;
while (index < Integer.MAX_VALUE) {
Trace.println(index + ") just a test string to
Trace...");
index++;
}
}
}
====================================================================
-------------------------------------------------------------------------
Ray Burns Internet: ###@###.###
FTP Software, Inc.
2 High Street Phone: (508)659-6447
North Andover, MA 01845 Fax: (508)659-6038
-------------------------------------------------------------------------