That line does look kind of leaky though. Is menu deleted properly? Are you sure the line is not being run? Debuggers can lie sometimes. Try a full rebuild and make sure to check it in debug mode.
If you want, put some messagebox before and after the call to the constructor and see if the code is run.
If it were run, the menu would be deleted properly--but I'm know that I'm never calling the method. I can put the "delete menu;" immediately after the allocation with the same results. "printf" shows that the code is in fact not being run (yes, being careful to flush IO buffers too).
you may want to check out VLD, which will give you more useful info when a leak is detected
I've used VLD before, and I've found that it sometimes doesn't pick up memory leaks. In this case, it reports "No memory leaks detected." on exit.
Actually, the problem isn't reproducible in a separate example, which, as I mentioned, points to it being some kind of problem within the application itself. I just don't know exactly what kinds of problems to look for. This:
My guess would be that with your line commented out the compiler is able to dead-strip swathes or even the entirety of the qt library from your project.
The memory leak itself might be resulting from some global constructor within the qt library that gets called when your line is present, but is stripped out when the line is not present.
That's just a guess though. I'd recommend you learn the tools necessary to track down memory leaks more directly rather than through trial and error. If your memory leak is reported then presumably there's some associated information, if it's only the address, then you might have some luck with a hardware breakpoint on that address of the leak which may shed some light.
. . . was kindof my guess, but as above the fact that the problem isn't reproduced in a simple example would seem to suggest otherwise.