QuickLogger
QuickLogger copied to clipboard
High memory consumption
In some tests I noticed a high increase in RAM memory, where it goes up and down to a certain "minimum limit" this minimum limit increases with the amount of logs sent.
In one example, when opening the application, it starts with around 10mb and with each batch of 500k logs, consumption increases to 500mb and drops to 20mb, with each new upload, this minimum increases. In the test, sending many logs, I noticed a significant increase, easily reaching the minimum of 800mb.
Looking at the "Quick.Logger.pas" code with the application in debug, I can see in the "TThreadProviderLog.Destroy destructor" in "fLogQueue.Free" that the memory is freed at that moment when the program ends.
While debugging I also realized that there may be a problem with the queue. In the image, we can see the "fQueue" items, we have 10 items. In the first log ever sent, index 0, the object is "cleaned", but not removed/deleted. At index 1 we have a new log about to be sent, and the other positions are null.
Could there be a memory consumption problem due to these items that are sent but not completely deleted from the fQueue?
QuickLogger internally uses techniques similar to TList. To avoid continuous memory reallocations, the size of arrays is increased, not one by one, but by a larger amount, up to a certain size, to accommodate new items. It's a performance-related consideration. The "empty spaces" you see are pointers to objects. If they are set to nil, the memory consumption is minimal and should not be affected. Nevertheless, I will review the code to ensure that no bugs have inadvertently crept in.