Plugin distorts under debug (vc17) but is fine under release (x86 & x64)

Hi,

I’ve developed an effect. When I try it with Debugger (vc2017 & Reaper) it distorts and goes bonkers (CPU spikes, etc). But if I build the release (x86 & x64) it works as designed.

I can’t find anything in the forum or elsewhere on-line about this.

Does anyone have any pointers that might help to identify the problem and find a solution?

1 Like

debug code can contain blocking calls, e.g. writing to the console. DBG is not safe to be used in the audio thread. (You may get away wit a few single ones, but in doubt remove them)

But that is a shot into the dark without code…

Maybe with debug build under the debugger the code just becomes too inefficient to run in realtime? How does the CPU load look like with the release build, is it already close to maximum?

The release code is stable at approx 2%

Then I would guess like daniel that there is something compiled in with the debug builds that makes it run bad, like heavy jasserts or console/debugger outputs. You are not allocating memory in the audio thread, are you? You might get away with that in release builds, but it might be much slower with debug builds. (It’s still highly not recommended to allocate in the audio thread, at least not with the standard memory allocators.)

I’m not doing any console writes or similar - I’m simply letting it run, so I can do step-through to trace the code.

It’s a bit difficult to select a piece of code that is at fault, because the releases work well.

It could be jasserts actually, that’s something to explore.

The debug code can be very slow if you have wrapped optimisation code (for example SSE2). 2% in release maybe is already enough to use more than one CPU core in debug mode. You can only use one core if your code is single threaded.

What is the code actually doing? Is it just straight up math calculations or is something like disk I/O or queuing into buffers (that might resize) involved?

I don’t think there is any problem. A debug build is not meant to be used in a standard environment, it’s meant to be debugged.

1 Like

fair point, simply made

That is normal. I’ve been working with a plugin which consumed about 800% of CPU in debug build compared to 20-30% in release build. CPU meter eg. in Ableton Live gives a good enough estimate about the CPU usage of a plugin.