Strange RAM usage
- OS, Version, Architecture (e.g. Windows 8.1 x64): Linux mint 18.3 x64 / Ubuntu 16.04 x64
- JRE Vendor, Version (e.g. Oracle JDK 8u151): openjdk 1.8.0_181
Expected behaviour
Running app should use less than 32mb RAM.
Actual behaviour
Running app eats about 400mb RAM.
Steps to reproduce the issue
Create new project with one Main.java class with following code:
package fr.delthas.skype;
public class Main {
public static void main(String[] args) throws Exception {
Skype skype = new Skype("username", "password");
skype.connect();
System.out.println("Done");
}
}
Run project and see memory usage using system monitor.
For example, I cannot even run this app on my VDS because of Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
To find the cause of such memory usage, generate a heap dump and analyse it with VisualVM. You will see which classes use the most memory.
Hi!
Here's screenshots from VisualVM:

Am I doing it wrong?
P.S. Also I can send you full heap dump if it'll help to investigate problem.
If you're running VisualVM on the same computer you're running JavaSkype, you can indeed simply create a heap dump in VisualVM by right-clicking on the process
.
I can see on your second screenshot that there 3 byte arrays containing 100 million elements, which is quite large. Click on the fields and references buttons
to open the corresponding panels. The fields panel will show you the fields on a specific byte[] instance, while the references panel will show you the oppositie direction, ie "what objects are the parent of this instance?". By opening the successive references you can easily which where are these byte arrays and what uses them. For example, on another project: you can see the char[] array belongs to a string, which belongs to a hashmap inside a jsonobject, ..., inside a Launcher instance:
. Knowing this reference tree lets you know exactly what is this field that takes so much space. And then, either this field belongs to an instance of a class in JavaSkype or it belongs to one of the classes you have created.
This is how you debug memory usage. In any case, if you'd like I can investigate the issue if you send me the heap dump.
No fields, no references for this byte[]s. But for other (and mostly other byte[]s) classes it is.
This is tar.gz with two dumps: heapdumps.tar.gz. Maybe you have more time for investigation.