1

I have an older PC with a Intel(R) Pentium(R) 4 CPU 2.53GHz and 2 GB of RAM. I'm iterating through javax.mail.Message instances and am wondering about upper limits on memory usage.

Assuming "regular" sized messages, how many can be comfortably loaded? Tens, hundreds of thousands? Millions?

Just looking for some ballpark WAG's please.

The heap as so:

run:
DEBUG: nntp: newsrc loading /home/thufir/.newsrc
DEBUG: nntp: newsrc load: 5 groups in 16ms
Aug 05, 2012 3:52:17 AM net.bounceme.dur.usenet.driver.FetchBean <init>
INFO: max 259522560
Aug 05, 2012 3:52:17 AM net.bounceme.dur.usenet.driver.FetchBean <init>
INFO: allocatedMemory 16252928
Aug 05, 2012 3:52:17 AM net.bounceme.dur.usenet.driver.FetchBean <init>
INFO: freeMemory 14160912
Aug 05, 2012 3:52:17 AM net.bounceme.dur.usenet.driver.FetchBean <init>
INFO: totalFreeMemory 257430544
Aug 05, 2012 3:52:17 AM net.bounceme.dur.usenet.driver.FetchBean <init>
INFO: useMemory 2092016

I'm iterating through Message's which are loaded from a local Leafnode NNTP server using the GNU NNTP library.

The headers for the message are examined, and then, when appropriate, some headers are persisted to the database with JPQL.

This is on Ubuntu 11.10 GNOME classic, by the way.

Community
  • 1
  • 1
Thufir
  • 8,216
  • 28
  • 125
  • 273
  • what is the size of the memory of your heap? as You can't assign the whole RAM to java heap. – Bharat Sinha Aug 05 '12 at 10:41
  • @BharatSinha I updated with some output from the heap. – Thufir Aug 05 '12 at 10:54
  • 1
    How many objects shouldn't matter but the memory they take up does. How about explaining what your application does ? Perhaps some optimization is possible. – James P. Aug 05 '12 at 10:58
  • @JamesPoulson They're pretty vanilla Message objects from gmane.com, text only for the most part. Some might have a JPEG, but that would be a minority. – Thufir Aug 05 '12 at 11:09
  • Given you don't have much memory, I would look to minimize the number and size of objects. While Java can handle millions of objects, they use memory and create an overhead for the garbage collector. Using primitives and minimize discarding objects can improvement perform (as would upgrading your hardware ;) – Peter Lawrey Aug 05 '12 at 13:24

1 Answers1

0

Well I would say that it depends of heap memory space you allowed for the Java Virtual Machine.

You can listen to memory manager notifications on heap space. If enter on the exceeded state, stop loading more messages, round down the message to a value you would like then paginate the results.

cavila
  • 7,834
  • 5
  • 21
  • 19