Skip to content
This repository has been archived by the owner on Apr 9, 2019. It is now read-only.

Strange RAM usage #48

Open
IriaSomobu opened this issue Aug 13, 2018 · 5 comments
Open

Strange RAM usage #48

IriaSomobu opened this issue Aug 13, 2018 · 5 comments

Comments

@IriaSomobu
Copy link

  • 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

@delthas
Copy link
Owner

delthas commented Oct 8, 2018

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.

@IriaSomobu
Copy link
Author

Hi!

Here's screenshots from VisualVM:
image
image

Am I doing it wrong?

@IriaSomobu
Copy link
Author

IriaSomobu commented Oct 8, 2018

P.S. Also I can send you full heap dump if it'll help to investigate problem.

@delthas
Copy link
Owner

delthas commented Oct 8, 2018

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 image.

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 image 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: image. 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.

@IriaSomobu
Copy link
Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants