Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Spoon classes consuming much memory #5574

Closed
bhatnagar444 opened this issue Dec 8, 2023 · 2 comments
Closed

[Bug]: Spoon classes consuming much memory #5574

bhatnagar444 opened this issue Dec 8, 2023 · 2 comments
Labels

Comments

@bhatnagar444
Copy link

Describe the bug

As per the initial analysis, Spoon classes are consuming more memory and giving out of memory error for our application.
Our application deals with processing files in Java project and extracting few information out of it.

We are using Spoon to collect all metadata of the files.
So for Smaller applications having 1500-1600 files it is working as expected but for bigger applications having 10000-15000 files it is giving memory issue.

We analyzed memory consumption using Memory Analyzer Tool (MAT) and found that Spoon classes are taking more spacing and standing on top 5 positions.

I can state few code in the below section and also would like to know if there is any hack or some other Spoon code which can handle the same.

Source code you are trying to analyze/transform

CtType
CtClass
CtInterface
CtField
CtLocalVariable
CtAssignment
CtInvocationImpl
CtConditionalImpl

Above are some of the classes which we are using like below -

for (CtField<?> ctField : model.getElements(new TypeFilter<>(CtField.class))) {
				String variableValue = "";
				String variablePath = ctField.getPath().toString();
				fileName = file.getName();
				String variableName = ctField.getSimpleName();
				if (ctField.getAssignment() != null) {
					variableValue = ctField.getAssignment().toString();
				}
				String variableLineNumber = String.valueOf(ctField.getPosition().getLine());
				List<String> variableDetailsList = new ArrayList<>();

				variableDetailsList.add(variableValue);
				variableDetailsList.add(variablePath);
				variableDetailsList.add(variableLineNumber);

				variableDetails.put(variableName, variableDetailsList);
				if (ctField.isFinal()) {
					isFinalConstantsUsedInSameFile.add(variableName);
				}
				if (ctField.isStatic()) {

					isStaticVariable.put(variableName, file.getName());
				}
			}

Source code for your Spoon processing

we can have any java file 
but multiple files causing issue.

Actual output

No response

Expected output

Out of Memory issue

Spoon Version

10.2.0

JVM Version

Java 17

What operating system are you using?

Windows and Linux both

@I-Al-Istannen
Copy link
Collaborator

Hey,

can you share a bit more information about your used and available memory, as well as maybe a MAT screenshot of the top objects/classes? If possible, a heap dump would be useful too. I am using spoon to analyze and convert Javadoc in e.g. the JDK itself (which is not a small project by any means) and it comfortably runs with <8 GiB of memory. It would probably work with less too, but I haven't tested that.

@bhatnagar444
Copy link
Author

Issue resolved

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

No branches or pull requests

2 participants