Re: performance and memory usage.
- From: Chris Smith <cdsmith@xxxxxxx>
- Date: Sun, 12 Feb 2006 10:19:21 -0700
arnold <arnold@xxxxxxxxxxx> wrote:
Thats actually quite terrible memory utilisation.
It's not all that bad; you're just storing a lot of data. In any case,
it's a realtively small constant multiple of what you'd get from any
other language.
In that case I have some questions:
1- Is there a more efficient way of storing this in memory, so you could
store up to, say, 100 million objects?
3- Are there any methods of making the data structures themselves more
memory efficient.
There are a few things you could do, if you're really desperate. For
example, you can save a lot of space by re-implementing HashMap and
ArrayList to use primitive int data instead of pointers to objects of
class Integer.
2- Is there a method of creating simple data placeholders which are not
objects, similar to structs in c/c++.
No.
In C I could write this so the program would not require more than
approx 48MB. (where approx 32MB is the real data and 16 MB is the arrays
with the pointers to the structures containing the data).
No, you couldn't. You're still ignoring the overhead for memory
allocation data structures. That overhead exists in C as well as in
Java.
The only difference is that in Java, objects carry an additional 8 bytes
or so of object header, and that the HashMap and ArrayList classes work
with Object and not int (solvable, as I mentioned, if you are willing to
re-implement those classes).
To me its seems that you should not really use java for in-memory
storage, except for smaller data sets.
You should, ideally, use a database for storing large data sets.
Ideally, you wouldn't implement your own database anyway, in any
language.
It's definitely possible to implement a database in Java if you so
desire, but you wouldn't store everything in object-oriented data
structures; instead, you'd use memory mapped files and java.nio.Buffer
to access the data. In-memory data structures are designed to be
convenient and capable for manipulating working data, not to be an
efficient means of data storage.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
.
- Follow-Ups:
- Re: performance and memory usage.
- From: Roedy Green
- Re: performance and memory usage.
- From: arnold
- Re: performance and memory usage.
- From: tom fredriksen
- Re: performance and memory usage.
- References:
- performance and memory usage.
- From: arnold
- Re: performance and memory usage.
- From: Chris Smith
- Re: performance and memory usage.
- From: arnold
- performance and memory usage.
- Prev by Date: Re: you are not logged in
- Next by Date: Re: Text displayed when mouse a coordinate
- Previous by thread: Re: performance and memory usage.
- Next by thread: Re: performance and memory usage.
- Index(es):
Relevant Pages
|
Loading