DefaultAllocator re-used by multiple player instances (trimOnReset = false) should not be trimmed unconditionally by SampleDataQueue.reset()
Open
@marcbaechinger is already working on this.
Since Feb 3, 2025.
needs triage
question
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
I tried to use a common DefaultAllocator for multiple players (with trimOnReset = false) as suggested in the constructor:
/**
* Constructs an instance without creating any {@link Allocation}s up front.
*
* @param trimOnReset Whether memory is freed when the allocator is reset. Should be true unless
* the allocator will be re-used by multiple player instances. If set to false, trimming can
* be forced by calling {@link #setTargetBufferSize(int)} manually when required.
* @param individualAllocationSize The length of each individual {@link Allocation}.
*/
public DefaultAllocator(boolean trimOnReset, int individualAllocationSize) {
this(trimOnReset, individualAllocationSize, 0);
}
However, when I tried to trim it manually at the end of all playbacks, I noticed the total bytes allocated was already 0. It turns out SampleDataQueue already called allocator.trim() unconditionally multiple times, destroying each-other's preallocations.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.