Opened 14 years ago
Closed 7 years ago
#1323 closed defect (rejected)
The ItemImage property leads to high memory consumption
Reported by: | abeham | Owned by: | architects |
---|---|---|---|
Priority: | medium | Milestone: | |
Component: | Core | Version: | 3.3.2 |
Keywords: | Cc: |
Description ΒΆ
The image obtained from the VS2008ImageLibrary resource manager is created anew every time the property is called. This leads on the one hand to somewhat higher memory consumption (even though this is just a small bitmap it seems to have quite an impact), but on the other hand also to leaked memory as this bitmap is not disposed anywhere.
The discussed solution so far is to remove the virtual declaration from the ItemImage property and introduce in Item a protected static Bitmap itemImage that can be set in the static initializer of a derived class defining an own icon. The property just returns this variable.
Change History (8)
comment:1 Changed 14 years ago by gkronber
comment:2 Changed 14 years ago by swagner
- Owner changed from swagner to abeham
- Status changed from new to assigned
comment:3 Changed 14 years ago by swagner
- Milestone changed from HeuristicLab 3.3.3 to HeuristicLab x.x.x
comment:4 Changed 14 years ago by abeham
- Priority changed from high to medium
comment:5 Changed 12 years ago by gkronber
This ticket is not resolved even after #1651 which introduced static image properties, as the Bitmap is still created via the ResourceManager each time the static getter is called.
comment:6 Changed 7 years ago by abeham
- Owner changed from abeham to architects
I assume we can just delete this
comment:7 Changed 7 years ago by gkronber
Fine by me.
comment:8 Changed 7 years ago by jkarder
- Milestone HeuristicLab 3.3.x Backlog deleted
- Resolution set to rejected
- Status changed from assigned to closed
I dislike the idea of static initializers for this. Can't we just have a property in Item that caches the bitmap, calling a protected virtual method CreateImage that can be overridden in sub-classes. On all subsequent calls the cached image instance is returned.
If we want to have one Bitmap per type instead of one Bitmap per Item instance we can still make the itemImage field static, however, we probably also need to make the ItemImage getter thread safe.