Memory issue

28 views
Skip to first unread message

sc3...@gmail.com

unread,
Aug 26, 2020, 7:55:04 PM8/26/20
to beadsproject
Hi,

I'm on Linux and using Jack.
I'm creating a drum sequencer with Beads,
using the SamplePlayer object to play the drum sounds.

While the sequencer is running the memory is constantly going up
and eventually also Jack gets into trouble with the cpu load.

I've analysed a heapdump and noticed that the issue is the amount
of float arrays in bufferStore in AudioContext:Screenshot_20200827_013522.png

My code that is responsible for the issue:
public void messageReceived(Bead message) {
for (File sound : currentSound2data.keySet()) {
DrumPlayerData data = currentSound2data.get(sound);
if (!data.isMute()) {
for (int step : data.getSteps()) {
if (clockCounter == step) {
Gain g = new Gain(beadsJackPlayer.getAudioContext(), JACK_OUTPUTS,
data.getVolume());
SamplePlayer samplePlayer = new SamplePlayer(beadsJackPlayer.getAudioContext(),
SampleManager.sample(sound.getAbsolutePath()));
g.addInput(data.getOutIndex(), samplePlayer);
beadsJackPlayer.getAudioContext().out.addInput(data.getOutIndex(), g,
data.getOutIndex());
}
}
}
}

So for each loop and each step I'm creating a new Gain and a new SamplePlayer.

I've tried working around it by having having for each step 1 Gain and 1 SamplePlayer object and then setting the Gain and setting the sample, but then I get only sound during one loop.

Anybody with some help ?

Thanks
Regards

Ollie Bown

unread,
Aug 26, 2020, 10:13:05 PM8/26/20
to beadsp...@googlegroups.com
Yeah you’re adding these things but not destroying them, so they keep mounting up.
A SamplePlayer will destroy itself once it plays the sample, but a Gain object will not.

Something like the following will ensure that the Gain gets killed too:

samplePlayer.addKillListener(new KillTrigger(g)); 

Ollie

On 27 Aug 2020, at 9:54 am, sc3...@gmail.com <sc3...@gmail.com> wrote:

Hi,

I'm on Linux and using Jack.
I'm creating a drum sequencer with Beads,
using the SamplePlayer object to play the drum sounds.

While the sequencer is running the memory is constantly going up
and eventually also Jack gets into trouble with the cpu load.

I've analysed a heapdump and noticed that the issue is the amount
of float arrays in bufferStore in AudioContext:<Screenshot_20200827_013522.png>

My code that is responsible for the issue:
public void messageReceived(Bead message) {
for (File sound : currentSound2data.keySet()) {
DrumPlayerData data = currentSound2data.get(sound);
if (!data.isMute()) {
for (int step : data.getSteps()) {
if (clockCounter == step) {
Gain g = new Gain(beadsJackPlayer.getAudioContext(), JACK_OUTPUTS,
data.getVolume());
SamplePlayer samplePlayer = new SamplePlayer(beadsJackPlayer.getAudioContext(),
SampleManager.sample(sound.getAbsolutePath()));
g.addInput(data.getOutIndex(), samplePlayer);
beadsJackPlayer.getAudioContext().out.addInput(data.getOutIndex(), g,
data.getOutIndex());
}
}
}
}

So for each loop and each step I'm creating a new Gain and a new SamplePlayer.

I've tried working around it by having having for each step 1 Gain and 1 SamplePlayer object and then setting the Gain and setting the sample, but then I get only sound during one loop.

Anybody with some help ?

Thanks
Regards


--
You received this message because you are subscribed to the Google Groups "beadsproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beadsproject...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beadsproject/0ad62347-4ace-4007-bc21-ef9ebfbaa2dan%40googlegroups.com.
<Screenshot_20200827_013522.png>

sc3...@gmail.com

unread,
Aug 27, 2020, 3:09:39 AM8/27/20
to beadsproject
Thank you Ollie,
samplePlayer.setKillListener(new KillTrigger(g)); 
fixes the issue indeed.

Regards.


Reply all
Reply to author
Forward
0 new messages