473,750 Members | 2,209 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java performance problem

Hi,

I have developed a java application that interacts with a database.
Now i've the folowing problem:

- I have a list retrieved from the database(about 200 records);
- for each, i do a Jlabel constructed from an html String;
- for each JLabel i construct a JPanel e add it to the main panel.

this works fine, but when there's an inactivity in the application
(about 30 minutes), the main panel disapear and the application
freeze. i don't know the reason for that (perhaps a lack of memomy
???).The application runs in a PIII 600mhz with 256 mb of ram.

Somebody can help me???

Thanks.
Jul 17 '05 #1
11 3547
Um? I can't think why it would hang for 30 minutes, 200 records doesn't
sound like much data. I've seen java render HTML JLabel slowly before (but
not that slowly!).

Have you tried removing the html, just use plain text in your JLabels?
Presumably you're using HTML because you want some nice formatting in your
JLabels..?

Have you tried adding your Resultset values into a JTable?

--

** http://www.tabletoolkit.com **
Aggregate a JTable to an arbitrary level to create your own pivot tables
"Jos? Cardoso" <jo********@yah oo.com> wrote in message
news:7e******** *************** ***@posting.goo gle.com...
Hi,

I have developed a java application that interacts with a database.
Now i've the folowing problem:

- I have a list retrieved from the database(about 200 records);
- for each, i do a Jlabel constructed from an html String;
- for each JLabel i construct a JPanel e add it to the main panel.

this works fine, but when there's an inactivity in the application
(about 30 minutes), the main panel disapear and the application
freeze. i don't know the reason for that (perhaps a lack of memomy
???).The application runs in a PIII 600mhz with 256 mb of ram.

Somebody can help me???

Thanks.

Jul 17 '05 #2
> Um? I can't think why it would hang for 30 minutes, 200 records doesn't
sound like much data. I've seen java render HTML JLabel slowly before (but
not that slowly!).

Have you tried removing the html, just use plain text in your JLabels?
Presumably you're using HTML because you want some nice formatting in your
JLabels..?

Have you tried adding your Resultset values into a JTable?


No, i need to show a lot of information for each row, thats why i choose html.

My program is something like that.

public class1{

public class1(){
...
}

public list1(){
// creates a JButton for each row
// each button listner creates a 2nd object -> class2 c2 = new class2()
c2.list2();
}

}

public class2{

public class2(){
...
}

public list2(){
// creates a JLabel for each row
}
}

I was seeing my taskmanager, and my memory goes to the 40.000 kb for javaw.exe,
when i run the program and enter in list2.

Then every time that i call list2, memory for javaw starts goes up to 80.000kb.

It seems like he isn't releasing the memory for objects created.
Jul 17 '05 #3
jo********@yaho o.com (Jos? Cardoso) wrote in message news:<7e******* *************** ****@posting.go ogle.com>...
Hi,

I have developed a java application that interacts with a database.
Now i've the folowing problem:

- I have a list retrieved from the database(about 200 records);
- for each, i do a Jlabel constructed from an html String;
- for each JLabel i construct a JPanel e add it to the main panel.

this works fine, but when there's an inactivity in the application
(about 30 minutes), the main panel disapear and the application
freeze. i don't know the reason for that (perhaps a lack of memomy
???).The application runs in a PIII 600mhz with 256 mb of ram.

Somebody can help me???

Thanks.


Hi,
Perhaps you are doing the list retrieval and JLabel creation right
in the Swing thread. That would explain the "freeze". You may want to
do the list retrieval in a separate thread. The creation of JLabels is
probably best done in a separate thread as well, though Sun apparently
recommends that UI components are best created in the Swing thread
under some situations. Then get the Swing thread to repaint the window
(using invokeLater(), for example).

The blog:
http://www.clientjava.com/blog/2004/...059428000.html
presents an excellent approach to class threading problems with Swing.

Javalpha.
Jul 17 '05 #4
On 30 Aug 2004 11:16:13 -0700, Jos? Cardoso wrote:
No, i need to show a lot of information for each row, thats why i choose html.


have you considered/tried convertint that table to
a JList? A JList can accept a custom ListCellRendere r,
and AFAIU, only the items in the visible area are liable
to get the HTML overhead..

HTH

comp.lang.java,
comp.lang.java. developer,
comp.lang.java. help

Please also note that .developer is not a
valid group* and three groups too many **.

* <http://www.physci.org/codes/javafaq.jsp#gro ups>
** <http://www.physci.org/codes/javafaq.jsp#xpo st>

Follow-Ups set top c.l.j.help only

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 17 '05 #5
> Hi,
Perhaps you are doing the list retrieval and JLabel creation right
in the Swing thread. That would explain the "freeze". You may want to
do the list retrieval in a separate thread. The creation of JLabels is
probably best done in a separate thread as well, though Sun apparently
recommends that UI components are best created in the Swing thread
under some situations. Then get the Swing thread to repaint the window
(using invokeLater(), for example).

The blog:
http://www.clientjava.com/blog/2004/...059428000.html
presents an excellent approach to class threading problems with Swing.

Javalpha.

Hi,
My problem isn't the retrieval, is after that. Java don't release the
memory used during the retrieval, and when the user click on the
button that make the same retrieval, the memory increases and after
that freezes.
Jul 17 '05 #6
I think my problem is in java allocated memory. It uses memory for the
objects created and don't release it. I was working in my application
until he reaches the 80mb of memory, and if i minimize my GUI, the
memory for my process cames to 11mb. Otherwise the memory keeps
climbing and hangs the application.

Is there any way to release the memory or destroy the objects ?
Jul 17 '05 #7
On 31 Aug 2004 08:34:13 -0700, Jos? Cardoso wrote:
I think my problem is in java allocated memory.


Have you tried a JList?
<http://google.com/groups?selm=1rk hi290ye6qx%24.1 bzin0hkbcvhy.dl g%4040tude.net>
There is no need for there to be any more than
a 'screenful' of the HTML (for rendering) at any time..

But, ..by the way, we have not seen an example
of your code, that might be the problem..

Cut out the D/B stuff and create an example
that creates 200 items for rendering using
dummy strings/HTML.

For further tips on an example..
<http://www.physci.org/codes/sscce.jsp>

Now, it seems you may not have got my earlier
reply, you are cross-posting to three groups,
one of which is not valid, *PLEASE* *STOP* *IT*.

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 17 '05 #8
jo********@yaho o.com (Jos? Cardoso) wrote in message news:<7e******* *************** ****@posting.go ogle.com>...
I think my problem is in java allocated memory. It uses memory for the
objects created and don't release it. I was working in my application
until he reaches the 80mb of memory, and if i minimize my GUI, the
memory for my process cames to 11mb. Otherwise the memory keeps
climbing and hangs the application.

Is there any way to release the memory or destroy the objects ?


Hi, here are some thoughts on how I would approach your problem.
First, try using the "-verbose:gc" option of your JVM, to see whether
the GC runs and, if so, whether it is successful in reclaiming memory.
You can also experiment with the "-Xmx" option to the JVM to increase
the maximum heap size (to say 128 MB) and see whether the allocated
memory saturates at some point. (BTW, the command "java -?" will
display all standard options available while "java -X" will display
non-standard options.)

Secondly, consider nulling out object references when you are sure
they won't be accessed again. CAUTION: Premature nulling is a bug and
may require lots of unit testing to catch via NullPointerExce ptions.

Thirdly, consider running the GC under program control using
System.gc(). This is not recommended in general because it is best to
let the JVM decide when to run the GC. You could perhaps run the GC
before each list retrieval. (This is just a thought, I don't know
enough about your app to say whether this is a good idea.)

Finally, consider using garbage collectors other than the defaut. JDK
1.4 includes no less than <a href=
"http://www-106.ibm.com/developerworks/java/library/j-jtp11253/">
6 separate garbage collectors</a>. Without knowing more about your
application, I cannot say whether this will be helpful or which one is
a good candidate to try.
Jul 17 '05 #9
tks for your tips.

after analise my program, i think that i´ve a problem in the
structure.

My program is something like that

public class1{
....
public met1(){
class2 = new class2();
}
}

public class2{
....
public met2(){
class3 = new class3();
}
}

public class3{
....
public met3(){
.....
....
button listener
class1 = new class1();
}
}

when i execute my program he works fine, but the memory allocated for
the process javaw.exe starts climb, he doesn't release the memory
taken.

A strange thing happens when i minimize my gui with the mouse, now he
dealocates the memory take by the process.... i don't understand why.
i agree that the structure isn't very good, but i don't see how can i
redefine it. The program should do the folowing:

- have a panel with a list of buttons(machine names) obtained from a
database.
- when we press a button, he must show a list of services for the
selected machine.
- when we choose a service, he must show the material used in that
service.
- after that we press a button and the program must list again the
services(relate d with the original machine selected).

All this must be showed in the same panel.

This is an appication that runs with a touch screen
tks
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4440
by: Zach | last post by:
This is all on linux using jdk1.3. My application is written in AWT, no swing. The application requires running it on the host machine and tunneling the GUI back to a client. I've been doing this via an ssh session. In the building the GUI works pretty much as if I was running it directly from the host machine, no lags or performance problems. Over longer distances I start to see some lagging, the GUI loses some responsiveness, it's...
11
9267
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
133
8568
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
10
4269
by: Alex Gerdemann | last post by:
Hello, I have spent a bunch of time converting a Java program I wrote to C++ in order to improve performance, and have found that it is not necessarily faster. Specifically, I'm writing a circuit simulator, so I must first parse the netlist file. The program goes through an input file, and makes a hash_set of unique nodes (std::string's). The words are then sorted and numbered by copying the hash_set into a vector and sorting. ...
30
2816
by: Mike Cox | last post by:
Hi. I recently ran a benchmark against two simple programs, one written in Java and the other in C++. The both accomplish the same thing, outputting "Hello World" on my screen. The C++ program took .5 seconds to complete on my 400 Mhz PC while the Java program took 6.5 seconds. I am running the SUSE 8.2 Linux distribution. Why is Java that much slower than the C++ program? I read on Slashdot that Java was almost as fast as C++. ...
2
1907
by: Rafael Faria | last post by:
Hi All, We are starting a large data warehousing project using DB2 8.2 on AIX. There is a direction to move any new internal development to Java and a question was raised: Would it be a good idea to have all stored procedures that we might need (ETL, additional transformers, etc) for this project and any other project written in Java as opposed to SQL/P? Does anyone have any number or experience in terms of performance differences?
0
768
by: Lakshmi | last post by:
Hi All, I am having performance issues with the .NET client calling the Java Webservice running on axis. Have detailed the problem below. Please help. I wrote a webservice in Java. Lets name this WebService1. (using Apache Axis 1.1) Scenario 1: -----------
2
6964
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
0
9575
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9394
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9338
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4712
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.