-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Pepelis, Aaron
Sent: Friday, April 06, 2001 10:33 AM
To: [EMAIL PROTECTED]
Subject: memory leak... some one help, please!!why is there a memory leak in this?
it just keeps grow and growing and growing...
someone help me please... this brought a over night test up to 166MB of memory usage...
thanks
aaron
import javax.swing.*;
import java.awt.*;
import javax.swing.text.*;public class BufferedOutputArea extends JTextArea
{private int size_of_buffer;
private int cut_back = 0;
String tempString;
public BufferedOutputArea( int buffer)
{
this(buffer, 0);
}
public BufferedOutputArea( int buffer, int cut_back)
{
size_of_buffer = buffer;
this.cut_back = cut_back;
}
public void setBufferSize(int buffer)
{
size_of_buffer = buffer;
}
public int getBufferSize()
{
return size_of_buffer;
}
public void append(String str)
{
tempString = getText()+str;
super.append(str);
if (tempString.length() > this.size_of_buffer)
{
try
{
System.out.println("hit "+str + "\n" + size_of_buffer + " " + cut_back + " " + tempString.length());
// setText(getText(cut_back, tempString.length()));
getDocument().remove(0,tempString.length() - this.size_of_buffer + cut_back);
System.out.println(""+getText().length());}
catch (BadLocationException e)
{
}
}
setCaretPosition(getText().length());
}public static void main(String [] args)
{
JFrame frame = new JFrame();
BufferedOutputArea output = new BufferedOutputArea(5000, 2000);
JScrollPane scroll = new JScrollPane(output);
scroll.setAutoscrolls(true);
frame.getContentPane().add(scroll);
frame.setSize(500,500);
frame.setVisible(true);
output.append("hello you think\nthat you are so cool\njust because your gnigg?\n");
try
{
for (int i= 0; i < 400; i++)
{
output.append("fudge this out put " + i + "\n3444444444444444444444444444444444444999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n" );Thread.sleep(300);
}
}
catch (Exception e)
{}
}
}
Title: memory leak... some one help, please!!
Can
you give us more details? When running this program
as is,
I do not see the growth that you do, especially since
it
stops at 400. Maybe it's the version of Java or the platform
you
are running?
Jeff
- memory leak... some one help, please!! Pepelis, Aaron
- Re: memory leak... some one help, please!! John Zukowski
- RE: memory leak... some one help, please!! Neil Thorne
- RE: memory leak... some one help, please!! John Zukowski
- RE: memory leak... some one help, please!! Jeff Leuschner
- RE: memory leak... some one help, please!! Paul Brinkley
- RE: memory leak... some one help, please!! Pepelis, Aaron
- RE: memory leak... some one help, please!! Pepelis, Aaron
- RE: memory leak... some one help, please!! Song, Mingjian
- RE: memory leak... some one help, please!! Pepelis, Aaron
