mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-10 23:57:25 -05:00
[WIP] Implements reusable sample buffers across all components. This
produces a significant reduction in memory usage, especially for tuners like the airspy and hackrf that produce 10/20 MSPS sample rates. This is observed to be around 66% reduction in peak memory usage and provides a more stable memory utilization across time reducing stress on the garbage collector. Use of these reusable memory buffers will be pushed further down into the processing chain modules to ensure we keep new object creation to the lowest levels possible.
This commit is contained in:
@@ -36,9 +36,9 @@ public class OverflowableTransferQueue<E>
|
||||
private IOverflowListener mOverflowListener;
|
||||
private Source mSourceOverflowListener;
|
||||
|
||||
private LinkedTransferQueue<E> mQueue = new LinkedTransferQueue<E>();
|
||||
private AtomicInteger mCounter = new AtomicInteger();
|
||||
private AtomicBoolean mOverflow = new AtomicBoolean();
|
||||
protected LinkedTransferQueue<E> mQueue = new LinkedTransferQueue<E>();
|
||||
protected AtomicInteger mCounter = new AtomicInteger();
|
||||
protected AtomicBoolean mOverflow = new AtomicBoolean();
|
||||
private int mMaximumSize;
|
||||
private int mResetThreshold;
|
||||
|
||||
@@ -73,6 +73,21 @@ public class OverflowableTransferQueue<E>
|
||||
setOverflow(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
overflow(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the buffer is in an overflow state. The element argument is thrown away. Override this method
|
||||
* in subclasses to perform any necessary cleanup action(s).
|
||||
*
|
||||
* @param e element that is being thrown away due to an overflow condition
|
||||
*/
|
||||
protected void overflow(E e)
|
||||
{
|
||||
//No-op. Override in subclass to perform any cleanup actions during overflow
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user