out of memory & high CPU consumption on reading in files

hi experts,

i've designed a search runnable class.

it searches for particular (matched) items in RSS(XML) documents stored on local drive, let say just 2000 files.

the matched items then appended in JTable.

i've 2 problems right now.

1. sometimes my application gives "out of memory" exception during all above process, normally it happened after 500 or 600 files read.

2. while searching more than 90% CPU consumed.

i want to handle "out of memory" exception and make it smooth search application, that during search operation user may do its other work concurrently and smoothly.

for xml file parser, i've used JDOM, after i get the relevant items, i make null all objects which i don't have further need.

but it seems that while adding in JTable , all memory is occuppied by JTable, because i've tested my app, by commenting the code which adds new rows to JTable, then i don't get "out of memory" error.

please help me

regards

[1010 byte] By [naeemga] at [2007-11-27 10:56:49]
# 1

How about not storing all that in a JTable?

You are storing it all to file, so why not load the files as needed instead of having all that data loaded into memory the whole time.

robtafta at 2007-7-29 12:05:14 > top of Java-index,Java Essentials,Java Programming...
# 2

all data already in their respective files.

i'm making search program for those files.

and search results are appended in JTable for user as list.

e.g.

search in file 1.xml.

5 items found

items appended to JTable.

search next file

2 items found

items appended to JTable

total items now 7 in JTable.

the process goes on untill whole directory of those files searched.

this is requirment to save all data in JTable at once.

it should not be problematic for JTable, as far as i've tested with only 3000 rows, sometimes less sometimes greater.

naeemga at 2007-7-29 12:05:14 > top of Java-index,Java Essentials,Java Programming...
# 3

3000 rows should not cause this. There must be some place where you are storing large ammounts of data. You could run java with the -Xmx512M option, that will help greatly. Java defaults to 64M of max memory, you are storing that much somewhere.

robtafta at 2007-7-29 12:05:14 > top of Java-index,Java Essentials,Java Programming...
# 4

i read about Xms command,

i used as its described at

http://www.jguru.com/faq/view.jsp?EID=424214

but java gave error of invalid arguments.

if by increasing memory my problem can be solved, then how to programmatically increase it, i've searched too much on web, but failed to find any solution.

naeemga at 2007-7-29 12:05:14 > top of Java-index,Java Essentials,Java Programming...
# 5

If you need to mess with -Xmx you are doing something wrong in my opinionl.

Are you closing every file?

Are you reading the entire file into memory?

Are you releasing the data you read from the file when you've searched it?

Or are you just hoping that all the files will fit into memory at the same time? Never assume that. Never assume that even one file will fit into memory.

ejpa at 2007-7-29 12:05:14 > top of Java-index,Java Essentials,Java Programming...