wolfpld / tracy

Frame profiler
https://tracy.nereid.pl/
Other
8.67k stars 598 forks source link

Mutex instrumentation leaks #691

Closed plekakis closed 6 months ago

plekakis commented 6 months ago

Hey again, I am doing a stress test with locking/unlocking several mutexes many times per frame and it seems that the memory keeps going up and up and "FreeAssociatedMemory" is never called, apart from when disconnecting from the profiler. Not sure if this is expected, but the culprit seems to be in BeforeLock(), calling Profiler::QueueSerial();. I don't see how that is ever freed. In my exaggerated example, I run out of memory within 5 seconds of run time (allocates almost 10GB of data which is never freed!)

Is this something wrong or perhaps local to me?

wolfpld commented 6 months ago

FreeAssociatedMemory is used to free additional memory that queue items may point to. There are no references of such kind in locking related queue items.

QueueSerial in BeforeLock will not execute when the profiler is not connected, this is checked by the TRACY_ON_DEMAND ifdefed code path.

plekakis commented 6 months ago

Ah so Tracy is usually meant to be used with TRACY_ON_DEMAND? Otherwise if it's not defined, it will leak afaict.

wolfpld commented 6 months ago

No. You are asking Tracy to record a large amount of data and it is doing exactly this. With no server connected this data has nowhere to go. When a server connection is established, the buffers will not be freed, but will be reused.

plekakis commented 6 months ago

Ok I understand now :) Sorry for the confusion, closing this issue.