Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Reuse for allocating oscillators: String #5264

Merged
merged 1 commit into from
Oct 17, 2021

Conversation

baconpaul
Copy link
Collaborator

This commit gives an API which allows us to reuse rather
than reallocate the memory buffers that objects need
at play time. Right now it only deals with the string
oscillator and still does 'extra' allocation on the audio
thread, but has a reasonable pre-allocate and re-use
strategy. In the future the overflow allocs could be
off thread but for now it's a simple save and reuse
approach.

Closes #4840

@baconpaul baconpaul force-pushed the memory-pool-string-4840 branch from b6b2eea to 5931cbd Compare October 17, 2021 12:39
@baconpaul baconpaul changed the title Memory Reuse for allocating oscillators: String Do Not Merge: Memory Reuse for allocating oscillators: String Oct 17, 2021
Copy link
Collaborator

@selenologist selenologist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code looks good to me, AFAICT each operation leaves things in correct state and overflows seem to be prevented.
However, there is a mismatch in signedness between size_t position and the ints that you may want to address, though I can't see any issue.

src/common/SurgeMemoryPools.h Outdated Show resolved Hide resolved
src/common/MemoryPool.h Show resolved Hide resolved
src/common/MemoryPool.h Outdated Show resolved Hide resolved
@baconpaul baconpaul changed the title Do Not Merge: Memory Reuse for allocating oscillators: String Memory Reuse for allocating oscillators: String Oct 17, 2021
This commit gives an API which allows us to reuse rather
than reallocate the memory buffers that objects need
at play time. Right now it only deals with the string
oscillator and still does 'extra' allocation on the audio
thread, but has a reasonable pre-allocate and re-use
strategy. In the future the overflow allocs could be
off thread but for now it's a simple save and reuse
approach.

Thanks to Luna for a review, and also glad I added
that test!

Closes surge-synthesizer#4840
@baconpaul baconpaul force-pushed the memory-pool-string-4840 branch from f495d5b to 36334e9 Compare October 17, 2021 14:30
@baconpaul baconpaul merged commit 749fe08 into surge-synthesizer:main Oct 17, 2021
@baconpaul baconpaul deleted the memory-pool-string-4840 branch October 17, 2021 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

String Oscillator allocates/deallocates on voice on
2 participants