C++ custom chop : TouchDesigner has run out of CPU memory

Hi, I imagine this is probably a noob mistake in my c++ coding, as I just got into it yesterday, but I have my second c++ chop, and somehow despite showing in the kb of memory consumption, after I feed it enough data it eventually crashes touch, giving me this message first:

Any good advice on how to approach pinpointing the issue? I’m using visual studio 2019.

Thanks!

Hi Lucas, it’s hard to say without more details, it might be that you’re allocating memory every frame without freeing it? Are you creating new c++ objects or using malloc in your execute() loop?

Otherwise besides simplifying your code / commenting out some bits until the error is gone to narrow it down I’m afraid there’s no easy fix! The joys of c++.

Hey Vincent! Thanks for the input.

Ya I took the route for now of simplifying and reducing as much as possible. I think I’m onto something, a select chop that is selecting my c++ chops from around the network is actually causing the error, narrowed it down to crashing when it tries to select a c++ chop of mine that has wonky info like this:

I am VERY new to c++, clearly still some learning to do, but seems if I can capture whatever edge case is generating that and just nullify the chop and output something else, might fix my issue.

Will report back either way.

Thanks again!

got it! my issue was that I tried to set info->startIndex to a negative number accidentally when certain conditions weren’t true. Somehow, it was causing the weird stretched node viewer you can see above, and the start/end had some really strange values in them.

Now, when certain conditions are not met, I just set numSamples, numChannels, and startIndex to some small/default values that wont cause issues.

1 Like