Solved

Java Memory Problems using large Datasets

Posted on 2006-11-17
5
199 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

863 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

22 Experts available now in Live!

Get 1:1 Help Now