Re: Memory use

I created a little test program (at the end of this email), and observed the following: If I do _not_ do a System.gc() just before printing out the memory usage info, then the values support your observation (17.3MB versus 12.3). However, after nulling out the data array and doing a garbage collection, the values become 5.3MB and 8.3MB, respectively. Therefore, your observation might not be completely representative of how much memory is actually required. As far as I can tell, since your range set has 255 elements, the data actually stored in the FlatField should be in bytes.

Hope that helps...


Here's the test program:

import java.*;
import visad.*;
import java.lang.*;

public class olver {
public static void main(String[] a) {
  try {
  RealType rt1 = new RealType("xc");
  RealType rt2 = new RealType("yc");
  RealType rt3 = new RealType("rc");
  RealTupleType dt = new RealTupleType(rt1,rt2);
  FunctionType ft = new FunctionType(dt, rt3);
  Integer2DSet ds = new Integer2DSet(1000,1000);
  Integer1DSet[] rs = { new Integer1DSet(rt3, 255)};
  //FlatField ff = new FlatField(ft, ds, null, null, rs, null);
  FlatField ff = new FlatField(ft, ds, null, null, null, null);
  float[][] data = new float[1][1000 * 1000];
  int z=0;
  for (int i=0; i<1000; i++) {
    for (int j=0; j<1000; j++) {
      data[0][z] = i+j;
  data = null;
  double totalMemory = (double) Runtime.getRuntime ().totalMemory ();
  double freeMemory = (double) Runtime.getRuntime ().freeMemory ();
  double usedMemory = (totalMemory-freeMemory);
  int percent = (int)(100.0*(usedMemory/totalMemory));
  totalMemory = totalMemory/1000000.0;
  usedMemory = usedMemory/1000000.0;
System.out.println("#### total, used, percent="+totalMemory+" +usedMemory+" "+percent);

  } catch (Exception e) {e.printStackTrace(); }

Hi all.

I'm working with Satellite Images, and I'm using visad to visualizate
them.  I need that visad use less memory, then I try to construct the
FlatField in this way:

new FlatField( func_domain_range, domain_set,null,null,new Integer1DSet[]
{new Integer1DSet(varRaster,255)},null);

but it spend more memory that in this way:

new FlatField( func_domain_range, domain_set,null,null,null,null);

Why the first one use more memory?


Olver Hernández
Facultad de Minas
Universidad Nacional de Colombia
Sede Medellín

Tom Whittaker (tomw@xxxxxxxxxxxxx)
University of Wisconsin-Madison
Space Science and Engineering Center
Cooperative Institute for Meteorological Satellite Studies
Phone/VoiceMail: 608.262.2759

  • References:
  • 2002 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: