Replace EvictingQueue with own implementation
For some unknown reason the EvictingQueue didn't evict or evicted only partially. Nevertheless it caused an OutOfMemoryError.
This commit is contained in:
parent
1dd432dbd9
commit
335233f473
|
@ -10,11 +10,13 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
@ -27,7 +29,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.EvictingQueue;
|
||||
import com.squareup.moshi.JsonAdapter;
|
||||
import com.squareup.moshi.Moshi;
|
||||
|
||||
|
@ -66,7 +67,7 @@ public class MyFreeCamsClient {
|
|||
private static int messageId = 31415; // starting with 31415 just for fun
|
||||
private Map<Integer, Consumer<Message>> responseHandlers = new HashMap<>();
|
||||
|
||||
private EvictingQueue<String> receivedTextHistory = EvictingQueue.create(100);
|
||||
private Queue<String> receivedTextHistory = new LinkedList<>();
|
||||
|
||||
private MyFreeCamsClient() {
|
||||
moshi = new Moshi.Builder().build();
|
||||
|
@ -193,6 +194,9 @@ public class MyFreeCamsClient {
|
|||
super.onMessage(webSocket, text);
|
||||
heartBeat = System.currentTimeMillis();
|
||||
receivedTextHistory.add(text);
|
||||
while(receivedTextHistory.size() > 100) {
|
||||
receivedTextHistory.poll();
|
||||
}
|
||||
msgBuffer.append(text);
|
||||
Message message;
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue