Solved

Java Memory Problems using large Datasets

Posted on 2006-11-17
5
206 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

621 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