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 29888 - Please remove static icons and data from BeanInfos
Summary: Please remove static icons and data from BeanInfos
Status: VERIFIED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: Diff (show other bugs)
Version: 3.x
Hardware: All All
: P3 blocker (vote)
Assignee: Martin Entlicher
URL:
Keywords: PERFORMANCE
Depends on:
Blocks: 14943
  Show dependency tree
 
Reported: 2003-01-09 08:49 UTC by Petr Nejedly
Modified: 2003-07-02 12:28 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Nejedly 2003-01-09 08:49:35 UTC
DiffSettingsBeanInfo uses static images and static
BIs data. This is considered a memory leak
in this context.

For loading images, use
org.openide.util.Utilities.loadImage directly
in getImage without any caching (Utilities will do
SoftCaching for you).

Create BeanDeascriptor and PropertyDescriptors
just on demand without any caching, Introspector
will cache it itself.

You can look at beaninfos in org.netbeans.beaninfo
for an example.
Comment 1 Martin Entlicher 2003-01-09 13:24:51 UTC
Fixed in the main trunk.
The class simplified, all static fields removed with the exception of
icon names.

/cvs/diff/src/org/netbeans/modules/diff/DiffSettingsBeanInfo.java,v 
<--  DiffSettingsBeanInfo.java
new revision: 1.5; previous revision: 1.4
Comment 2 Petr Nejedly 2003-01-09 14:13:53 UTC
The static data is gone, thanks.

What about the icons? Do you plan to provide some later?
Is that complicated code necessary?
Most of the BIs use simple
public Image getIcon(int type) {
  if ((type == BeanInfo.ICON_COLOR_16x16) ||
      (type == BeanInfo.ICON_MONO_16x16)
    return Utilities.loadImage("org/.....gif"); // NOI18N
  else 
    return Utilities.loadImage("org/....32.gif); // NOI18N
}

And if you don't have icons yet, you can omit the code at all.
Comment 3 Martin Entlicher 2003-01-09 16:06:55 UTC
> What about the icons? Do you plan to provide some later?
Well, maybe, I'm not sure whether it will be necessary.

> Is that complicated code necessary?
At first I wanted to delete the whole getIcon() method body and 4
pointers to icon names and return just null.
But the structure may be handy later if I decide to add the icons and
the 4 static empty pointers do not seem to me as a big problem.

But to have a clean bytecode, I've removed the 4 static empty
pointers, commented the method body and return just null :-)

/cvs/diff/src/org/netbeans/modules/diff/DiffSettingsBeanInfo.java,v 
<--  DiffSettingsBeanInfo.java
new revision: 1.6; previous revision: 1.5
Comment 4 Petr Nejedly 2003-01-09 16:40:29 UTC
Better.
Eventually you may comment out the whole method as SimpleBeanInfo
does return null for you already ;-)
Comment 5 Martin Entlicher 2003-01-10 11:11:31 UTC
You're nitpicking ;-)
You've ask for it:
/cvs/diff/src/org/netbeans/modules/diff/DiffSettingsBeanInfo.java,v 
<--  DiffSettingsBeanInfo.java
new revision: 1.7; previous revision: 1.6