0

I have a application that reads log messages from syslog, parses it and breaks it down into 4 fields i.e "timestamp", "facility", "severity" and "message".

I display this entire data in a JTable (with 4 columns). I also simultaneously write these data to xml files.

The problem is that the current DefaultTableModel runs out of memory when we keep adding rows(whenever new log messages arrive). So is there any other table model that can fit my use case.(i.e the JTable must display all the log messages to the user without running out of memory).

If at all I try to implement my very own custom table model to update from the xml files when model reaches a certain limit, what are the things I must keep in mind (i.e problems, ideas) when designing such a model.

Note: I cannot use a database

Thanks.

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
Nitish P
  • 43
  • 9
  • The question is, how much do you really need to keep in memory? Can trim off old messages? I would also seriously consider looking at using something like a single user database system like [H2](http://www.h2database.com/html/main.html) or [HSQLDB](http://hsqldb.org/) - IMHO – MadProgrammer Sep 27 '13 at 04:50
  • Actually since its a logger i need all the log messages to displayed to the user.About using a database, will it take too much time to implement them ( i do not know much about them).Could you give any already implemented examples related to this so that i can refer to it? – Nitish P Sep 27 '13 at 06:06
  • You could explore the use of a disk backed collection, but it would require you to implement your own `TableModel` – MadProgrammer Sep 27 '13 at 06:10
  • disk backed collection are there any that are under free license.(Since what my company is developing is a propertry based IDE tool).Could give some tips to what problems i can face when going ahead such a design? – Nitish P Sep 27 '13 at 06:18

1 Answers1

2

Several possibilities:

  • Profile your application to identify possible spurious object allocation or retention, as shown here.

  • Alter the virtual machine's heap allocation, as shown here.

  • Explore a disk based paging scheme suited to your use-case.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045