Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,28 @@ public JfrOptionSet() {
}

public void validateAndAdjustMemoryOptions() {
maybeAdjustDefaults();
ensureValidMinimumSizes();
ensureValidMemoryRelations();
adjustMemoryOptions();
assert checkPostCondition();
}

/**
* We expect that Native Image executables will require lesser defaults than JFR on the JVM. So
* to reduce JFR native memory consumption, we use lower default values. We should not adjust
* default values too early (at build time) because if any settings are user defined, we
* shouldn't change any values.
*/
private void maybeAdjustDefaults() {
if (!globalBufferSize.isUserValue() && !globalBufferCount.isUserValue() && !memorySize.isUserValue()) {
globalBufferSize.setValue(globalBufferSize.defaultValue / 2);
globalBufferCount.setValue(globalBufferCount.defaultValue / 2);
// Update record of total size
memorySize.setValue(globalBufferSize.getValue() * globalBufferCount.getValue());
}
}

private void ensureValidMinimumSizes() {
if (memorySize.isUserValue() && memorySize.getValue() < MIN_MEMORY_SIZE) {
throw new IllegalStateException("The value specified for the JFR option 'memorysize' is too low. Please use at least " + MIN_MEMORY_SIZE + " bytes.");
Expand Down