EMMA Coverage Report (generated Sat Jun 02 16:47:50 EDT 2012)
[all classes][net.sf.madmap]

COVERAGE SUMMARY FOR SOURCE FILE [RetainedHeapTableModel.java]

nameclass, %method, %block, %line, %
RetainedHeapTableModel.java0%   (0/1)0%   (0/10)0%   (0/346)0%   (0/63)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RetainedHeapTableModel0%   (0/1)0%   (0/10)0%   (0/346)0%   (0/63)
<static initializer> 0%   (0/1)0%   (0/8)0%   (0/1)
RetainedHeapTableModel (Madmap, ArrayList, long, JTextArea): void 0%   (0/1)0%   (0/155)0%   (0/18)
childrenSummary (int): String 0%   (0/1)0%   (0/9)0%   (0/2)
getColumnClass (int): Class 0%   (0/1)0%   (0/5)0%   (0/1)
getColumnCount (): int 0%   (0/1)0%   (0/4)0%   (0/1)
getColumnName (int): String 0%   (0/1)0%   (0/5)0%   (0/1)
getLog (): JTextArea 0%   (0/1)0%   (0/3)0%   (0/1)
getRowCount (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getStack (int): Vector 0%   (0/1)0%   (0/30)0%   (0/9)
getValueAt (int, int): Object 0%   (0/1)0%   (0/124)0%   (0/28)

1/*
2 * Copyright 2008 Eric Caspole
3 * 
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5 * file except in compliance with the License. You may obtain a copy of the License at
6 * 
7 * http://www.apache.org/licenses/LICENSE-2.0
8 * 
9 * Unless required by applicable law or agreed to in writing, software distributed under
10 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11 * KIND, either express or implied. See the License for the specific language governing
12 * permissions and limitations under the License.
13 */
14 
15package net.sf.madmap;
16 
17import java.io.*;
18import java.util.*;
19import javax.swing.*;
20 
21 
22public class RetainedHeapTableModel extends MadmapTableModel {
23 
24  ArrayList   _objects;
25  long        _retSizes[];
26  boolean     _leakGuesses[];
27  long        _totalLiveSize;
28  int         _rows;
29  JTextArea   _retLog;
30  
31  private String[] columnNames = {
32    "Object Type",
33    "Object Address",
34    "Leak Guess?",
35    "Retained Size",
36    "Pct of Retained Size"
37  };
38  
39  private Class[] columnType = {
40    (java.lang.Class)((new String("")).getClass()),
41    (java.lang.Class)((new String("")).getClass()),
42    (java.lang.Class)((new String("")).getClass()),
43    (java.lang.Class)((new Long(0)).getClass()),
44    (java.lang.Class)((new Double(0.0)).getClass())
45  };
46    
47  public RetainedHeapTableModel( Madmap m, ArrayList objs, long liveSize, JTextArea log ) {
48        super(m);
49    _objects  = objs;
50    _rows     = _objects.size();
51    _retSizes = new long[_rows];    
52    _leakGuesses = new boolean[_rows];
53    
54    // record the ret size here in a list because the object field will 
55    // be reused for other calculations
56    for( int i = 0; i < _rows; i++ ) {      
57      _retSizes[i] = ((HprofHeapCollectable)_objects.get(i)).getRetainedSize();              
58      HprofHeapCollectable curr = (HprofHeapCollectable)_objects.get(i);
59      assert (curr != null) : "curr obj is null in retained obj input array" ;
60      Boolean b = (Boolean) getController().getGuesses().get(curr.addr());
61      if (( b != null ) && ( b == true )) {
62        _leakGuesses[i] = true;
63      } else {
64        _leakGuesses[i] = false;
65      }
66    }
67    
68    _totalLiveSize  = liveSize;
69    _retLog         = log;
70  }
71 
72  public Class getColumnClass(int c) {
73    return columnType[c];
74  }
75  
76  public String getColumnName(int col) {
77      return columnNames[col];
78  }
79 
80  public int getColumnCount() { return columnNames.length; }
81  public int getRowCount() { return _rows; }
82 
83  public JTextArea getLog() { return _retLog; }
84 
85  /**
86  * Returns the vector containing the strings of the allocation stack trace recorded in the hprof file.
87  * <p>
88  * Retrieves the object from the list of objects shown in the table, then retrieve the stack trace 
89  * vector from the object.
90  *
91  * @param  row   the row selected by the user in the retained heap table
92  *
93  */
94  public Vector getStack(int row) {
95    //HprofHeapCollectable hk = (HprofHeapCollectable)_objects.get(row);
96    HprofHeapAllocation hk = (HprofHeapAllocation)_objects.get(row);
97    int stackId = hk.getStackTrace();
98    if ( stackId != 0 ) {
99      HprofStackTraceData std = (HprofStackTraceData) getController().getStackTraces().get(stackId);
100      Vector stk = null;
101      if ( std != null ) { 
102        stk = std.getStackVector();
103      }
104      return stk;
105    } else {
106      return null;
107    }
108  }
109 
110  /**
111  * Retrieves the object from the list of objects shown in the table 
112  *
113  * @param  row   the row selected by the user in the retained heap table
114  *
115  */
116  public String childrenSummary(int row) {
117    HprofHeapCollectable hk = (HprofHeapCollectable)_objects.get(row);
118    return hk.toString();    
119  }
120 
121  
122  public Object getValueAt(int row, int col) { 
123    Iterator<HprofHeapAllocation>   ihoc3 = _objects.iterator();
124    int i = 0;
125 
126    while( ihoc3.hasNext() ) {
127      HprofHeapAllocation hk = ihoc3.next();
128      
129      if ( i == row ) {
130        if ( col == 0 ) {
131          HprofThreadData thd = null;
132          // Print the thread name as a convenience to the user, it is in the thread record
133          if ( hk.className().equals("java.lang.Thread") ) {
134            thd = (HprofThreadData) getController().getThreads().get( (int) hk.addr() );
135            if ( thd != null ) {
136              return  new String( hk.className() + " [ " + thd.name() + " ]" );
137            }
138          }
139          return new String( hk.className() );
140        } else if ( col == 1 ) {
141          return new String( Long.toHexString(hk.addr()) );
142        } else if ( col == 2 ) {
143          if ( _leakGuesses[i] == true ) {
144            return "Yes";
145          } else {
146            return null;
147          }
148        } else if ( col == 3 ) {
149          return _retSizes[i];        
150        } else if ( col == 4 ) {
151          long  rs            = _retSizes[i];        
152          double pctLiveSize  = ((double) rs / (double) _totalLiveSize)  *  (double)100.0;
153          return pctLiveSize;
154        }
155      }
156      i += 1;
157    }
158  
159    assert  true == false : "Should not reach here!" ;
160    return null;
161  }    
162};

[all classes][net.sf.madmap]
EMMA 2.0.5312 (C) Vladimir Roubtsov