I believe I have a double delete and some memory corruption happening somehow in my complex c++ application on OpenBSD. I would like to track down the first location my object is deleted, and any points at which deallocated memory is accessed.

I would usually look into valgrind, but it is linux only. Failing that, I would instrument my new and delete operators with some kind of tracking code, but I've been finding it difficult to determine the correct google search for this.

Is there any package for openbsd which will give me information on memory errors? Is there any kind of standard way to redefine new and delete to detect overflows, invalid accesses, double frees?

有帮助吗?

解决方案

This helps a lot:

man malloc

Debugging options can be enabled system-wide, environment-wide, or program-specific.

其他提示

I don't know if you are willing to use a third party tool, but C++ memory validator is very good.

http://www.softwareverify.com/cpp-memory.php

It isolates the memory/ handle leaks, tells you how much memory is leaked and shows you the position in the code. If only it could then fix the leak for you : ) 30 day free trial is available too.

I've used it to find leaks in my legacy C++ MFC application where the previous developer didn't seem to think there was a need to relase memory ever!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top