What to do against "makeSynthMsgWithTags: buffer overflow"

Hi

I use SC on Linux since 10 years, i always write the complete song into {…}.scope

After my code reaches a certain size, usually when the CPU usage goes above 50%, it gives this error:

ERROR: makeSynthMsgWithTags: buffer overflow
ERROR: Primitive ‘_NetAddr_SendMsg’ failed.

I read somewhere that there is a limit of 65500 bytes.

Is there a way to edit the SC source code, or other ways to increase this limit ?

Hello :wave:
As per my knowledge, this editing the source code to increase this limit might be possible, but it’s complex. You could also try optimizing your code or splitting it into smaller sections to avoid hitting the limit.

I hope this will help you.

Respected community member :smiling_face_with_three_hearts:

@Wako - the CPU usage isn’t the culprit here, but the size of the SynthDef that function:scope is creating to run it.
The way to optimize this is to break the code into smaller chunks as SynthDefs if possible - I have to say, that won’t necessarily be easy. The approach you are using was supported in SC2 because Spawn was used for adding to the processing graph, but with SC Server, the architecture really gives that control more over to you.
I don’t think changing the source code is the way to go. SC Server isn’t really made to be optimized for the way you are working with it. The Function:scope method was really made for limited backwards compatibility and for testing small chunks of code - I’d recommend avoiding it. Understanding how this is all working under the hood a little more is probably going to be the thing that gets you where you need to be.

Maybe that’s the maximum size of a UDP packet when you send the synthdef to the server.

I think TCP allows larger sizes; you can try that.

But the best would be to find a way to work with more modular synths.

Basically… what Josh said.

BUT… you’re relying on a convenience method to create a big SynthDef for you.

Convenience methods are not guaranteed to handle every case. Once you “grow up” in your SC usage, it’s time to learn what they are doing for you and take the reins for yourself.

You can .load big SynthDefs that are impossible to .send.

So, if you really prefer the working method of giant synthdefs, write e.g.

fork {
    SynthDef(\myBigDef, {
        ... hundreds of lines of ugens...
    }).load;
    s.sync;
    x = Synth(\myBigDef);
};

… and use s.scope, not {}.scope.

Modularizing into smaller synths is better, but if you really strongly dislike that idea, you can get around the UDP limit by not sending the big def over UDP at all – use a disk file instead (.load).

hjh

Hi jamshark70

I tried your solution on my current script where i reached the limit, and it works just fine. This solved my problem, without the need to change my dirty way of writing code. Thanks a lot!

(I do much additive synthesis, sometimes with loops inside loops, there i easy reached the maximum allowed size also with small amounts of code, which is difficult to break in parts)