Solved

Java Memory Problems using large Datasets

Posted on 2006-11-17
5
198 Views
Last Modified: 2010-03-31
Hi,
    I am working on a Java Swing Application where I am initially generating a lot of data randomly and storing it in a Vector and a 2-D Object array.  Without going into details I need to store it in both objects although depending on a user's selection one structure will have only the users selected records while the other Object contains all the cached data.  We need to make it work with as many as 50,000 records and are running up against memory problems because a GOTS tool we are also using is a memory hog.  We have 1Gig of memory on our workstations.  More than one method in the class will access the large data structures.

My question is, memory wise for these large datasets, where the large arrays and Vectors will be used by more than one method in the class, am I better off making the arrays and Vectors class member variables?  Or would it be better memory wise to declare the arrays and Vectors as local variables in a method and then pass them from method to method as parameters?

Please help,
Dave  

 
0
Comment
Question by:gdkinney_2
  • 3
  • 2
5 Comments
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17967001
It would be good idea to create array once and pass it around, creating new array involves a lot of memory
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17967012
i better approach would be - NOT to store the ResultSet in terms of array/vector, process it row by row!
0
 
LVL 24

Accepted Solution

by:
sciuriware earned 500 total points
ID: 17967029
Doesn't matter, you can calculate yourself how much of all those objects
will exist together; what you need to persist can't be local.

You could of course try to hold small numbers in short i.s.o. long
but I smell that it will not help you in your situation.

Start by running with a lot of initial memory:

java -Xmx1400m  or so, you will use the swapdisk of the system.

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 17967037
Note: I did not see the posts by Ajay-Singh.

Own remark: avoid growing array implementations like ArrayList

;JOOP1
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 17993634
:)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now