View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0030661 | Lazarus | LCL | public | 2016-09-28 13:54 | 2017-06-05 00:08 |
Reporter | jakyro | Assigned To | Michl | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
OS | Windows | ||||
Product Version | 1.6 | ||||
Target Version | 1.8 | Fixed in Version | 1.9 (SVN) | ||
Summary | 0030661: TTreeView memory leak (WARNING: TResourceCacheItem.IncreaseRefCount 1000 TPenHandleCache) | ||||
Description | TreeView memory leak. Create Win32/64 LCL application, add TreeView on MainForm, run and start resize MainForm until the message in console/log: WARNING: TResourceCacheItem.IncreaseRefCount 1000 TPenHandleCache WARNING: TResourceCacheItem.IncreaseRefCount 10000 TPenHandleCache I tested it on Windows 10.0.10586 and 10.0.14393. | ||||
Steps To Reproduce | Windows 10.0.10586/10.0.14393 lazarus-1.6.0-fpc-3.0.0-win32/win64 2016-02-15 1. Create LCL graphical application "Menu/File/New.../Project/Application". Create MainForm if not created. 2. Create TreeView on MainForm and add TreeView items 1 or more. 3. Uncheck "Project Options.../Config and Target/Win32 gui application (-WG)" to see console messages OR run application with argument "--debug-log=log.txt". 4. Run application. Start resize MainForm (for repaint TreeView) from current size to zero and back, until the message (or close application to save log.txt if application running with --debug-log): WARNING: TResourceCacheItem.IncreaseRefCount 1000 TPenHandleCache WARNING: TResourceCacheItem.IncreaseRefCount 10000 TPenHandleCache | ||||
Additional Information | WARNING: TResourceCacheItem.IncreaseRefCount 1000 TPenHandleCache WARNING: TResourceCacheItem.IncreaseRefCount 10000 TPenHandleCache | ||||
Tags | IncreaseRefCount, lcl, TPenHandleCache, TResourceCacheItem, ttreeview, warnings | ||||
Fixed in Revision | r55118 | ||||
LazTarget | - | ||||
Widgetset | Win32/Win64 | ||||
Attached Files |
|
|
|
|
How often do you need to resize? I can't reproduce the bug under Linux/Gtk2. Maybe Win32 only issue. |
|
Lazarus 1.7 r52861 FPC 3.0.0 i386-win32-win32/win64 I automated the resize: Counter = 165 WARNING: TResourceCacheItem.IncreaseRefCount 1000 TPenHandleCache Counter = 1665 WARNING: TResourceCacheItem.IncreaseRefCount 10000 TPenHandleCache Note: the TreevIew must have Items, otherwise this issue does not happen. |
|
While redrawing, all calls to TPen.FreeReference say: FReference.Allocated=FALSE and also in all calls to TPen.ReferenceNeeded it says FReference.Allocated=FALSE So, pens are added to the cache, but never seem to get deleted from it. |
|
How to fix it? I can not continue to create my project with this bug. |
|
I can't reproduce the bug under Windows either. Please attach an example unit to reproduce the problem. |
|
|
|
Sample project attached (tvpencache.zip). Unzip, build and run from commandline like this: C:\Users\Bart\LazarusProjecten\bugs\TreeViewPenCache>tvpencache | grep WARNING --before-context=1 Output on my system (Lazarus 1.7 r52861 FPC 3.0.0 i386-win32-win32 on Win7-64): Counter = 165 WARNING: TResourceCacheItem.IncreaseRefCount 1000 TPenHandleCache -- Counter = 1665 WARNING: TResourceCacheItem.IncreaseRefCount 10000 TPenHandleCache |
|
I can confirm this issue under win32. Does not happen with qt under win32, also does not happen under linux gtk2/qt. |
|
|
|
> I can not continue to create my project with this bug. I ran my sample program for > 500000 iterations. There were no errors, crashes or Windows complaining. Also heaptrace reported no memory leaks. So, whilst this is a bug, it should not prevet you from developing your program. |
|
Fixed in trunk. Please test and close if OK. Btw. there was no memory leak. A new pen wasn't created, because the parameter list was wrong, so Handle 0 was given back. For this Handle 0, the reference count was increased. |
Date Modified | Username | Field | Change |
---|---|---|---|
2016-09-28 13:54 | jakyro | New Issue | |
2016-09-28 13:54 | jakyro | File Added: treeview-cache.png | |
2016-09-28 14:01 | jakyro | Tag Attached: lcl | |
2016-09-28 14:01 | jakyro | Tag Attached: ttreeview | |
2016-09-28 14:01 | jakyro | Tag Attached: warnings | |
2016-09-28 14:01 | jakyro | Tag Attached: IncreaseRefCount | |
2016-09-28 14:01 | jakyro | Tag Attached: TPenHandleCache | |
2016-09-28 14:01 | jakyro | Tag Attached: TResourceCacheItem | |
2016-09-28 14:21 | Mattias Gaertner | Note Added: 0094851 | |
2016-09-28 15:24 | Bart Broersma | LazTarget | => - |
2016-09-28 15:24 | Bart Broersma | Note Added: 0094852 | |
2016-09-28 15:24 | Bart Broersma | Status | new => confirmed |
2016-09-28 15:47 | Bart Broersma | Note Added: 0094853 | |
2016-09-28 15:48 | Bart Broersma | Note Edited: 0094852 | View Revisions |
2016-09-30 04:54 | jakyro | Note Added: 0094878 | |
2016-09-30 08:45 | Mattias Gaertner | Note Added: 0094880 | |
2016-09-30 18:25 | Bart Broersma | File Added: tvpencache.zip | |
2016-09-30 18:28 | Bart Broersma | Note Added: 0094882 | |
2016-09-30 18:28 | Bart Broersma | Note Edited: 0094882 | View Revisions |
2016-09-30 18:28 | Bart Broersma | Note Edited: 0094882 | View Revisions |
2016-09-30 18:48 | Zeljan Rikalo | Note Added: 0094883 | |
2016-09-30 19:21 | jakyro | File Added: example_treeview_warning.zip | |
2016-09-30 21:52 | Bart Broersma | Note Added: 0094884 | |
2017-05-29 08:31 | Michl | Fixed in Revision | => r55118 |
2017-05-29 08:31 | Michl | Note Added: 0100733 | |
2017-05-29 08:31 | Michl | Status | confirmed => resolved |
2017-05-29 08:31 | Michl | Fixed in Version | => 1.9 (SVN) |
2017-05-29 08:31 | Michl | Resolution | open => fixed |
2017-05-29 08:31 | Michl | Assigned To | => Michl |
2017-05-29 08:31 | Michl | Target Version | => 1.8 |