Repository navigation
Fixes #587: Reduce Cloudlet memory footprint - #594
Merged
Merged
Conversation
- Cloudlet listener sets are now immutable lists managed by the Listeners helper (#586). They start as the shared List.of(), so Cloudlets without listeners don't allocate 3 empty HashSets. - requiredFiles starts as List.of() and a real list is only created on the first addRequiredFile. deleteRequiredFile is now O(n) instead of O(n^2). setRequiredFiles copies the given list, so adding files after setting an immutable list works. getRequiredFiles returns a read-only list. - New immutable shared UtilizationModel.FULL, used as the default CPU utilization model, instead of creating a UtilizationModelFull per Cloudlet. - Listeners.remove returns the same list when given null, since List.of().indexOf(null) throws NullPointerException. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 21 |
| Duplication | 0 |
🟢 Coverage 83.67% diff coverage · +0.16% coverage variation
Metric Results Coverage variation ✅ +0.16% coverage variation Diff coverage ✅ 83.67% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (0813444) 9111 4630 50.82% Head commit (06b0eab) 9136 (+25) 4657 (+27) 50.97% (+0.16%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#594) 49 41 83.67% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This was referenced Oct 20, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #587. Builds on the
Listenershelper from #586.Changes
HashSets are now immutable lists that start as the sharedList.of()and change throughListeners. Notifications use for-each loops.requiredFilesList.of(); a realArrayListis only created on the firstaddRequiredFile.deleteRequiredFileis now a singleremove(filename)(was O(n²) on aLinkedList).setRequiredFilescopies the given list, so an immutable list no longer breaks later adds.UtilizationModel.FULL(backed byUtilizationModelFullShared, whose setters do nothing), used as the default CPU model.Total: ~248 B per Cloudlet (~248 MB per 1M Cloudlets).
Behavior changes
getRequiredFiles()returns a read-only list (useaddRequiredFile/deleteRequiredFile).onFinishlistener list is cleared before notifying, so a listener added during the finish notification is kept for a later finish (consistent with Listener lists: lazy creation and safe changes during notification #586). Before, it was dropped.Listeners.remove(list, null)returns the same list instead of throwing an NPE (List.of().indexOf(null)throws). This keptremoveOnFinishListener(null)returningfalse, as before.UtilizationModel.FULLdo nothing. Users who need a configurable model can createnew UtilizationModelFull().Tests
mvn clean verify -Pintegration-tests: 583 tests, all passing.UtilizationModel.FULLand its no-op setters; listener duplicates, self-removal and addition during notification;requiredFilescases (immutable list given to the setter, delete with no files, add after deleting all files, read-only getter);Listeners.removewith null.CloudletListenersExample1,CreateCloudletAfterLastFinishedOneandDynamicCreationOfVmsAndCloudletsExampleran with no exceptions, with the same output as onmaster.Benchmark results
Measured with
MemoryFootprintBenchmark(cloudsimplus/cloudsimplus-benchmarks#10). It creates 100,000 Cloudlets and measures the heap they keep after a full GC (median of 5 rounds).CloudletSimpleThe measured saving matches the estimate in the table above, which splits it among the 3 changes. That's about 248 MB less heap per 1M Cloudlets.
"Before" is CloudSim Plus 8.5.1, so the difference includes all changes since that version, but it's exactly the saving estimated for this PR. Run with JDK 25.0.4 (Corretto), compressed oops,
-XX:+UseSerialGC.🤖 Generated with Claude Code