This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 117264

Summary: Some objects allocated via reflection are not recorded
Product: profiler Reporter: Alexander Kouznetsov <mrkam>
Component: BaseAssignee: Tomas Hurka <thurka>
Status: RESOLVED FIXED    
Severity: blocker    
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description Alexander Kouznetsov 2007-10-01 09:44:22 UTC
Product Version: NetBeans IDE Dev (Build 200709271200) 
Java: 1.6.0_02; Java HotSpot(TM) Client VM 1.6.0_02-b05 
System: SunOS version 5.10 running on x86; ISO646-US; en (nb)

X.class.newInstance() type of object creation is not recorded by the profiler.
Allocation via the new operator is recorded just fine. This issue becomes more
relevant the bigger the application where reflection is used more often.

When I perform allocation memory profiling (each 1 object allocation, no stack traces) of attached application, it
creates 1000 Object instances, but profiler shows only 17.

See also issue 71792
Comment 1 Alexander Kouznetsov 2007-10-01 09:44:45 UTC
Sample application:
http://www.netbeans.org/nonav/issues/showattachment.cgi/49733/Main.java
Comment 2 Tomas Hurka 2007-10-01 13:14:09 UTC
The problem is caused by so called "Inflation" mechanism. Reflection uses native code for first few invocations (default threshold is 15) and than switches to 
artificially generated classes to create new instances. Class.newInstance() caches default constructor and therefore you see only 16 instances. it works fine on 
other cases, since the java.lang.reflect.Constructor is not reused and therefore there is no inflation. Lowering priority to P3, since this is not common case. 
Since inflation threshold can be controlled by system property sun.reflect.inflationThreshold, there is easy workaround - run application with 
-Dsun.reflect.inflationThreshold=1000000
Comment 3 Tomas Hurka 2007-10-01 20:50:05 UTC
Fixed in trunk.