0

AWT Buffer Image

I can calculate that how much heap memory This Image Object will aquire ,

Like

BUfferedImage(W,H,TYPE)

then

Total memory used by it = W * H * 4

is there any way that i can estimate memory Usage

For Excel Spread Sheet and a Simple XML file that how much memory they will need if they are of specific size and/or contains specifics rows/nodes ?

Thanks

Mihir
  • 2,480
  • 7
  • 38
  • 57

2 Answers2

0

You can monitor your application when opening a file and get sensate estimation for future configuration: see for example hpjmeter: https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=HPJMETER

robermann
  • 1,722
  • 10
  • 19
0

This is not an easy problem. To start with, you need to know exactly what you want to measure. For a BufferedImage, you need to specify which TYPE because the number of bytes needed per pixel depends on it. For excel spread sheets and XML files, you need to specify which library you want to use.

Event then, the only way to know is by measuring. You can take several measurements and extrapolate - this is not guaranteed to be exactly correct but will yield useful estimates.

These posts show how you can do that:

The last post, "In Java, what is the best way to determine the size of an object?", only measures the size of the object itself, not the object graph that it creates.

This external link titled Again about determining size of Java object has an extension of the solution in the last post, which estimates the size of an object graph. It's too long to reproduce here (and it's not my code to copy) but the link has existed since 2007 so I believe it's quite stable.

Community
  • 1
  • 1
Erwin Bolwidt
  • 30,799
  • 15
  • 56
  • 79
  • thanks for your answer, but my problem is whenevr i open excel file having disk size larger than 39 mb and having 2 million records , my Java run time throws an OOM Error , so like in the BUfferedImage can i know here in advance by some other utility/code that how many bytes are required of memory to process this file , if this bytes available than process continue otherwise take the alternative roots. – Mihir Mar 01 '14 at 09:31