Source Code Cross Referenced for LivenessMemoryResultsSnapshot.java in  » IDE-Netbeans » cvsclient » org » netbeans » lib » profiler » results » memory » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » cvsclient » org.netbeans.lib.profiler.results.memory 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         * The Original Software is NetBeans. The Initial Developer of the Original
026:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
027:         * Microsystems, Inc. All Rights Reserved.
028:         *
029:         * If you wish your version of this file to be governed by only the CDDL
030:         * or only the GPL Version 2, indicate your decision by adding
031:         * "[Contributor] elects to include this software in this distribution
032:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
033:         * single choice of license, a recipient has the option to distribute
034:         * your version of this file under either the CDDL, the GPL Version 2 or
035:         * to extend the choice of license to its licensees as provided above.
036:         * However, if you add GPL Version 2 code and therefore, elected the GPL
037:         * Version 2 license, then the option applies only if the new code is
038:         * made subject to such option by the copyright holder.
039:         */
040:
041:        package org.netbeans.lib.profiler.results.memory;
042:
043:        import org.netbeans.lib.profiler.ProfilerClient;
044:        import org.netbeans.lib.profiler.client.ClientUtils.TargetAppOrVMTerminated;
045:        import java.io.DataInputStream;
046:        import java.io.DataOutputStream;
047:        import java.io.IOException;
048:        import java.text.MessageFormat;
049:        import java.util.ResourceBundle;
050:        import java.util.logging.Level;
051:
052:        /**
053:         * Results snapshot for Allocations Memory Profiling.
054:         *
055:         * @author Ian Formanek
056:         */
057:        public class LivenessMemoryResultsSnapshot extends
058:                MemoryResultsSnapshot {
059:            //~ Static fields/initializers -----------------------------------------------------------------------------------------------
060:
061:            // -----
062:            // I18N String constants
063:            private static final ResourceBundle messages = ResourceBundle
064:                    .getBundle("org.netbeans.lib.profiler.results.memory.Bundle"); // NOI18N
065:            private static final String MEMORY_LIVENESS_MSG = messages
066:                    .getString("LivenessMemoryResultsSnapshot_MemoryLivenessMsg"); // NOI18N
067:            // -----
068:
069:            //~ Instance fields ----------------------------------------------------------------------------------------------------------
070:
071:            /** [0 - nProfiledClasses] index: classId, average object age for class */
072:            private float[] avgObjectAge;
073:
074:            /** [0 - nProfiledClasses] index: classId, contains tracked live instrances # for this class -
075:             * assumption: smaller than allocated, thus only int */
076:            private int[] maxSurvGen;
077:            private int[] nTotalAllocObjects;
078:
079:            /** [0 - nProfiledClasses] index: classId, contains tracked allocated instrances # for this class */
080:            private long[] nTrackedAllocObjects;
081:            private int[] nTrackedLiveObjects;
082:            private long[] trackedLiveObjectsSize;
083:            private int currentEpoch;
084:
085:            /** used to keep track of total allocations number, which is in turn needed to monitor
086:             * JFluid tool's used heap space */
087:            private int nInstrClasses;
088:            private int nTotalTracked;
089:            private int nTrackedItems;
090:            private long maxValue;
091:            private long nTotalTrackedBytes;
092:
093:            //~ Constructors -------------------------------------------------------------------------------------------------------------
094:
095:            public LivenessMemoryResultsSnapshot() {
096:            } // No-arg constructor needed for above serialization methods to work
097:
098:            public LivenessMemoryResultsSnapshot(long beginTime,
099:                    long timeTaken, MemoryCCTProvider provider,
100:                    ProfilerClient client) throws TargetAppOrVMTerminated {
101:                super (beginTime, timeTaken, provider, client);
102:            }
103:
104:            //~ Methods ------------------------------------------------------------------------------------------------------------------
105:
106:            /**
107:             * @return An average object age for each class
108:             */
109:            public float[] getAvgObjectAge() {
110:                return avgObjectAge;
111:            }
112:
113:            /**
114:             * @return An array of maximum number of surviving generations for each class
115:             */
116:            public int[] getMaxSurvGen() {
117:                return maxSurvGen;
118:            }
119:
120:            public long getMaxValue() {
121:                return maxValue;
122:            }
123:
124:            /**
125:             * @return Number of classes
126:             */
127:            public int getNAlloc() {
128:                return nInstrClasses;
129:            }
130:
131:            public int getNInstrClasses() {
132:                return nInstrClasses;
133:            }
134:
135:            public long getNTotalTracked() {
136:                return nTotalTracked;
137:            }
138:
139:            public long getNTotalTrackedBytes() {
140:                return nTotalTrackedBytes;
141:            }
142:
143:            /**
144:             * @return An array of number of tracked allocations for each class
145:             */
146:            public long[] getNTrackedAllocObjects() {
147:                return nTrackedAllocObjects;
148:            }
149:
150:            public int getNTrackedItems() {
151:                return nTrackedItems;
152:            }
153:
154:            /**
155:             * @return An array of number of tracked live objects for each class
156:             */
157:            public int[] getNTrackedLiveObjects() {
158:                return nTrackedLiveObjects;
159:            }
160:
161:            public long[] getTrackedLiveObjectsSize() {
162:                return trackedLiveObjectsSize;
163:            }
164:
165:            public int[] getnTotalAllocObjects() {
166:                return nTotalAllocObjects;
167:            }
168:
169:            public void performInit(ProfilerClient client,
170:                    MemoryCCTProvider provider) throws TargetAppOrVMTerminated {
171:                MemoryCCTProvider.ObjectNumbersContainer onc = provider
172:                        .getLivenessObjectNumbers();
173:
174:                int len;
175:                len = onc.nTrackedAllocObjects.length;
176:                nTrackedAllocObjects = new long[len];
177:                System.arraycopy(onc.nTrackedAllocObjects, 0,
178:                        nTrackedAllocObjects, 0, len);
179:                len = onc.nTrackedLiveObjects.length;
180:                nTrackedLiveObjects = new int[len];
181:                System.arraycopy(onc.nTrackedLiveObjects, 0,
182:                        nTrackedLiveObjects, 0, len);
183:                len = onc.trackedLiveObjectsSize.length;
184:                trackedLiveObjectsSize = new long[len];
185:                System.arraycopy(onc.trackedLiveObjectsSize, 0,
186:                        trackedLiveObjectsSize, 0, len);
187:                len = onc.avgObjectAge.length;
188:                avgObjectAge = new float[len];
189:                System.arraycopy(onc.avgObjectAge, 0, avgObjectAge, 0, len);
190:                len = onc.maxSurvGen.length;
191:                maxSurvGen = new int[len];
192:                System.arraycopy(onc.maxSurvGen, 0, maxSurvGen, 0, len);
193:
194:                nInstrClasses = onc.nInstrClasses;
195:
196:                int[] tmp = client.getAllocatedObjectsCountResults();
197:                len = tmp.length;
198:                nTotalAllocObjects = new int[len];
199:                System.arraycopy(tmp, 0, nTotalAllocObjects, 0, len);
200:
201:                // Below is a bit of "defensive programming". Normally the sizes of arrays here should be same
202:                // except for nTotalAllocObjects, that is returned from the server, and may be shorter if some
203:                // instrumented classes have not propagated to the server yet.
204:                nTrackedItems = Math.min(nTrackedAllocObjects.length,
205:                        nTrackedLiveObjects.length);
206:                nTrackedItems = Math.min(nTrackedItems,
207:                        trackedLiveObjectsSize.length);
208:                nTrackedItems = Math.min(nTrackedItems, avgObjectAge.length);
209:                nTrackedItems = Math.min(nTrackedItems, maxSurvGen.length);
210:                nTrackedItems = Math.min(nTrackedItems, nInstrClasses);
211:                nTrackedItems = Math.min(nTrackedItems,
212:                        nTotalAllocObjects.length);
213:
214:                // Now if some classes are unprofiled, reflect that in nTotalAllocObjects
215:                //for (int i = 0; i < nTrackedAllocObjects.length; i++) {
216:                for (int i = 0; i < nTrackedItems; i++) {
217:                    if (nTrackedAllocObjects[i] == -1) {
218:                        nTotalAllocObjects[i] = 0;
219:                    }
220:                }
221:
222:                // Operations necessary for correct bar representation of results
223:                maxValue = 0;
224:                nTotalTrackedBytes = 0;
225:                nTotalTracked = 0;
226:
227:                //for (int i = 0; i < trackedLiveObjectsSize.length; i++) {
228:                for (int i = 0; i < nTrackedItems; i++) {
229:                    if (maxValue < trackedLiveObjectsSize[i]) {
230:                        maxValue = trackedLiveObjectsSize[i];
231:                    }
232:
233:                    nTotalTrackedBytes += trackedLiveObjectsSize[i];
234:                    nTotalTracked += nTrackedLiveObjects[i];
235:                }
236:
237:                currentEpoch = provider.getCurrentEpoch();
238:            }
239:
240:            public void readFromStream(DataInputStream in) throws IOException {
241:                super .readFromStream(in);
242:
243:                int len = in.readInt();
244:                nTrackedAllocObjects = new long[len];
245:
246:                for (int i = 0; i < len; i++) {
247:                    nTrackedAllocObjects[i] = in.readLong();
248:                }
249:
250:                len = in.readInt();
251:                nTrackedLiveObjects = new int[len];
252:
253:                for (int i = 0; i < len; i++) {
254:                    nTrackedLiveObjects[i] = in.readInt();
255:                }
256:
257:                len = in.readInt();
258:                maxSurvGen = new int[len];
259:
260:                for (int i = 0; i < len; i++) {
261:                    maxSurvGen[i] = in.readInt();
262:                }
263:
264:                len = in.readInt();
265:                trackedLiveObjectsSize = new long[len];
266:
267:                for (int i = 0; i < len; i++) {
268:                    trackedLiveObjectsSize[i] = in.readLong();
269:                }
270:
271:                len = in.readInt();
272:                avgObjectAge = new float[len];
273:
274:                for (int i = 0; i < len; i++) {
275:                    avgObjectAge[i] = in.readFloat();
276:                }
277:
278:                nInstrClasses = in.readInt();
279:
280:                len = in.readInt();
281:                nTotalAllocObjects = new int[len];
282:
283:                for (int i = 0; i < len; i++) {
284:                    nTotalAllocObjects[i] = in.readInt();
285:                }
286:
287:                nTrackedItems = in.readInt();
288:                maxValue = in.readLong();
289:                nTotalTrackedBytes = in.readLong();
290:                nTotalTracked = in.readInt();
291:                currentEpoch = in.readInt();
292:            }
293:
294:            public String toString() {
295:                return MessageFormat.format(MEMORY_LIVENESS_MSG,
296:                        new Object[] { super .toString() });
297:            }
298:
299:            //---- Serialization support
300:            public void writeToStream(DataOutputStream out) throws IOException {
301:                super .writeToStream(out);
302:
303:                out.writeInt(nTrackedAllocObjects.length);
304:
305:                for (int i = 0; i < nTrackedAllocObjects.length; i++) {
306:                    out.writeLong(nTrackedAllocObjects[i]);
307:                }
308:
309:                out.writeInt(nTrackedLiveObjects.length);
310:
311:                for (int i = 0; i < nTrackedLiveObjects.length; i++) {
312:                    out.writeInt(nTrackedLiveObjects[i]);
313:                }
314:
315:                out.writeInt(maxSurvGen.length);
316:
317:                for (int i = 0; i < maxSurvGen.length; i++) {
318:                    out.writeInt(maxSurvGen[i]);
319:                }
320:
321:                out.writeInt(trackedLiveObjectsSize.length);
322:
323:                for (int i = 0; i < trackedLiveObjectsSize.length; i++) {
324:                    out.writeLong(trackedLiveObjectsSize[i]);
325:                }
326:
327:                out.writeInt(avgObjectAge.length);
328:
329:                for (int i = 0; i < avgObjectAge.length; i++) {
330:                    out.writeFloat(avgObjectAge[i]);
331:                }
332:
333:                out.writeInt(nInstrClasses);
334:
335:                out.writeInt(nTotalAllocObjects.length);
336:
337:                for (int i = 0; i < nTotalAllocObjects.length; i++) {
338:                    out.writeInt(nTotalAllocObjects[i]);
339:                }
340:
341:                out.writeInt(nTrackedItems);
342:                out.writeLong(maxValue);
343:                out.writeLong(nTotalTrackedBytes);
344:                out.writeInt(nTotalTracked);
345:                out.writeInt(currentEpoch);
346:            }
347:
348:            protected PresoObjAllocCCTNode createPresentationCCT(
349:                    RuntimeMemoryCCTNode rootNode, int classId,
350:                    boolean dontShowZeroLiveObjAllocPaths) {
351:                return PresoObjLivenessCCTNode
352:                        .createPresentationCCTFromSnapshot(this , rootNode,
353:                                getClassName(classId), currentEpoch,
354:                                dontShowZeroLiveObjAllocPaths);
355:            }
356:
357:            void debugValues() {
358:                super .debugValues();
359:                LOGGER.finest("nTrackedAllocObjects.length: "
360:                        + debugLength(nTrackedAllocObjects) // NOI18N
361:                );
362:                LOGGER.finest("nTrackedLiveObjects.length: "
363:                        + debugLength(nTrackedLiveObjects) // NOI18N
364:                );
365:                LOGGER.finest("maxSurvGen.length: " + debugLength(maxSurvGen)); // NOI18N
366:                LOGGER.finest("trackedLiveObjectsSize.length: "
367:                        + debugLength(trackedLiveObjectsSize) // NOI18N
368:                );
369:                LOGGER.finest("avgObjectAge.length: "
370:                        + debugLength(avgObjectAge)); // NOI18N
371:                LOGGER.finest("nInstrClasses: " + nInstrClasses); // NOI18N
372:                LOGGER.finest("nTotalAllocObjects.length: "
373:                        + debugLength(nTotalAllocObjects) // NOI18N
374:                ); // NOI18N
375:                LOGGER.finest("nTrackedItems: " + nTrackedItems); // NOI18N
376:                LOGGER.finest("maxValue: " + maxValue); // NOI18N
377:                LOGGER.finest("nTotalTrackedBytes: " + nTotalTrackedBytes); // NOI18N
378:                LOGGER.finest("nTotalTracked: " + nTotalTracked); // NOI18N
379:                LOGGER.finest("currentEpoch: " + currentEpoch); // NOI18N
380:            }
381:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.