Florian Soko

Greenhorn
+ Follow
since Sep 07, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Florian Soko

Hi.

I'm trying to develop a simple swing application with JPA and Toplink as persistence provider using Netbeans IDE.

So what I try to do is saving my data in a MySQL database. I'm reading images from my harddrive and then save them in a blob field in my database table. After inserting 100 images with each 1 Megabyte, my 128Mb heap is filled up and my application throws an exception.

So what I've done is calling entityManager.clear() in my finished() method of my save task to clean up my persistence context, so all my objects are detached. But if i watch my memory usage in the "windows vista task manager", it is still growing with every inserted image. It's not growing as fast as without entityManager.clear() but it will still blast my heap size after running e.g. a whole day.

Can anyone help me to avoid this? I just want to create a simple swing application to save some entries in my database tables. Maybe I could do it with plain JDBC but I like the way the JPA stuff is working.

Thanks, Florian.



Yes this is working.


You gave me a pretty good idea how i should make use of the SwingWorker and my GUI is now loading while the task is running in the background.

Thanks for your help.
14 years ago
Hi guys.

I'm new to Swing and currently I'm having some problems. I want to observe a certain folder, and whenever a new image file is copied to it or created in the folder, i want to display it in my Swing Application. So far I've made a simple app with a panel and an ImageIcon which I've read from the file system. This is working fine.

Now I want to expand my application. I thought I could make a swing worker thread (which is running all the time to observe the folder for new files).
So my plan was to get the file list of the directory, then sleep the worker thread for a while and then read the files again. If the length of the file list is longer than before, then i can return the last fileitem.

However I'm running into some trouble. It looks like the Worker Thread has no sleep function. And also my plan to observe the folder results in either an endless loop or my GUI is frozen until the Thread is finished. Because the plan was to never let the Thread finish, my GUI will be frozen forever.


I'd appreciate if anyone has some better ideads to observe a folder or could help me with these Worker Threads.

Greetings Florian
14 years ago