[CM] some questions re S7, real-time use, and memory allocation

Iain Duncan iainduncanlists at gmail.com
Sun Nov 22 09:18:18 PST 2020


Hi folks, I tried hunting through s7.html for answers, so if I missed the
answer (due to not understanding) my apologies.

In my next release of scheme for max, I'm allowing one to specify which of
the two max threads an S7 object lives in, with all input to the object
promoted or deferred accordingly. This allows using S7 in timing critical
situations. It also means S7 can be running in the same thread as DSP. I'm
also working on a Pd port, which has only one thread, so S7 will be in the
audio thread.

I have read numerous articles on real-time audio coding that say "don't
malloc in the audio thread", because you never know when this could lead to
an operating system level disk swap. I've read various strategies to avoid
it, including pre-allocating pools of whatever you might allocate, or
pre-allocating a big chunk of memory so you allocate from memory that is
guaranteed not to need to swap. My questions:

- is there a way to do memory pre-allocation for S7 so that I can guarantee
that creating new objects isn't going to lead to OS level swapping? as in,
have S7 only allocate from a memory buffer I've already set aside? (RAM is
cheap, underruns are bad..)
- any thoughts about why you might or might not do this?
- any thoughts on how hard this would be to implement if it has not been
done?
- are there any alternative approaches I should look into?
- are there tools I could use to see how much is going on?

Any general input on this issue and how others deal with it or not would be
much appreciated!
iain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20201122/1faaeb6e/attachment.html>


More information about the Cmdist mailing list