Message-ID: From: "apgrucza (@apgrucza)" To: "postgresql-interfaces/psqlodbc" Date: Sun, 28 Apr 2024 11:34:08 +0000 Subject: Re: [postgresql-interfaces/psqlodbc] issue #8: Memory leaks detected in psqlodbc library In-Reply-To: References: List-Id: X-GitHub-Author-Login: apgrucza X-GitHub-Comment-Id: 2081443464 X-GitHub-Comment-Type: issue_comment X-GitHub-Issue: 8 X-GitHub-Repo: postgresql-interfaces/psqlodbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/postgresql-interfaces/psqlodbc/issues/8#issuecomment-2081443464 Content-Type: text/plain; charset=utf-8 I feel much the same as @progmachine in that I don't really understand the relationships between the various structs and the intended design around ownership of allocated memory. The mimalloc changes I made were simply adding a drop-in replacement for malloc which did not require me to understand all this. Without modern language features such a destructors and smart pointers, I'm not surprised there are memory leaks. When I added mimalloc and enabled `MIMALLOC_SHOW_STATS`, I did notice that it reported memory leaks (and the reports were more detailed in debug builds). But the problem does not lie with detecting memory leaks but knowing the correct way to fix them. I noticed the `_MEMORY_DEBUG_` symbol was added by @hiinoue for the purposes of finding memory leaks, but that was 18 years ago so I doubt he'd be able to assist now. If @progmachine were to attempt a fix, I wonder whether the current tests are comprehensive enough to guarantee that it does not introduce any bugs.