Enhancement
Critical
Major
Detail
Detail
Detail
#26090
Memory Leak because the TLObject "IMAPMailFolder" is listener at IMAPFolder
tl:IMAPMailFolder is a tl:TLObject. At the same time it is a listener to `IMAPFolder `. These are stored indirectly by the tl:MailServerProxy. From there, there are three reference chains to a GC root. Not all of them can be broken. This ultimately keeps tl:IMAPMailFolders permanently in memory, and with them their tl:KnowledgeBase and everything that goes with it.
Solution
tl:IMAPMailFolder is no longer a direct listener. Instead, there is a listener that holds tl:IMAPMailFolder via WeakReference. The listener removes itself if the reference to tl:IMAPMailFolder is null.
Test
Run the scripted tests in the demo. Create a [ Dump] just before the last tests are executed. Open it for example with [JavaResources#Profiler:JVisualVM|JVisualVM]. Open the histogram of the classes, filter for the class tl:DBKnowledgeBase and pay attention to the number of instances. There must be only one.