I am new to Java and really need your help.
I am currently using a queue, the receiving thread puts data in this queue, and the parser is reading this. But the problem is that the receiver can receive at an incredible maximum speed, for example, . 3000 / s, while the parser only analyzes 100 / s.
EDIT: I checked, the first turn remains at 100 or so, and after ten seconds it starts to grow at 100 for the second, and the crash is at 2000 or so. Is it possible that there is a memory leak?
My code (in a closed loop)
byte[] data = new byte[1024]; System.arraycopy(udpPacket.getData(), 0, data, 0, 1024); queue.offer(data);
The heap is filled up too fast and I get an outofmemory exception. I think the problem is that the queue is created using a linked list, and all pointers should be stored on the heap.
I know a version of C that does the same thing (using a buffer) but has much better performance, but due to deployment problems we can only use Java.
source share