BrianMc1958
asked on
How many objects at once is too many? (I know, it DEPENDS!)
Dear Experts,
I have an existing class that was designed to hold in memory basic information about a few HUNDRED customers at the same time. Now the business people would like to increase that to--possibly--a few HUNDRED THOUSAND customers at the same time. My first thought was I had to rewrite, but I thought I'd ask here first.
I'm storing each customer in a data bean, and storing all the data beans at once in a HashSet. There are about a dozen fields in the data bean--a few int's, a few String's, and a few long's. I'm afraid I have no idea how much actual memory such a bean takes up. And whatever it is, it would be multiplied a few hundred thousand times.
I know the answer is "It DEPENDS", but is that way too much memory to grab at once? Conversely, is it definitely NOT too much? (Have you done something similar in the real world?) Ballpark answers would be greatly appreciated...
Thanks,
BrianMc1958
I have an existing class that was designed to hold in memory basic information about a few HUNDRED customers at the same time. Now the business people would like to increase that to--possibly--a few HUNDRED THOUSAND customers at the same time. My first thought was I had to rewrite, but I thought I'd ask here first.
I'm storing each customer in a data bean, and storing all the data beans at once in a HashSet. There are about a dozen fields in the data bean--a few int's, a few String's, and a few long's. I'm afraid I have no idea how much actual memory such a bean takes up. And whatever it is, it would be multiplied a few hundred thousand times.
I know the answer is "It DEPENDS", but is that way too much memory to grab at once? Conversely, is it definitely NOT too much? (Have you done something similar in the real world?) Ballpark answers would be greatly appreciated...
Thanks,
BrianMc1958
ASKER
OK. Read that.
For the data alone I'm storing in the bean then, probably about 100 bytes. (The Strings are all short.) Then there are about a dozen standard getters and setters. There are simple hashCode, clone and equals overrides, and whatever "space overhead" any Object might have.
Would anyone like to take a guess at the total-bytes-per-bean? 200 bytes? 1,000 bytes?
Thanks...
For the data alone I'm storing in the bean then, probably about 100 bytes. (The Strings are all short.) Then there are about a dozen standard getters and setters. There are simple hashCode, clone and equals overrides, and whatever "space overhead" any Object might have.
Would anyone like to take a guess at the total-bytes-per-bean? 200 bytes? 1,000 bytes?
Thanks...
~ 150 bytes would be a good enough estimate
ASKER
OK. Can I have 500,000 of those at once in memory, for a total of 75,000,000 bytes? Ordinary PC's now come with ten times that amount of memory. My application will be running in the real world on servers that should have somewhere between 2 and 8 gig, and of course will have other applications running on them at the same time.
I'm guessing that if such a system can't spare 75 meg, it's got very serious problems anyway.
What do you think? Can I do it?
--BrianMc1958
I'm guessing that if such a system can't spare 75 meg, it's got very serious problems anyway.
What do you think? Can I do it?
--BrianMc1958
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
--BrianMc1958
--BrianMc1958
no worries :)
http://www.idevelopment.info/data/Programming/java/miscellaneous_java/Java_Primitive_Types.html