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

Add additional memory overhead for VirtualBox when --memory=max #15317

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
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
12 changes: 9 additions & 3 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ func validateChangedMemoryFlags(drvName string) {
if err != nil {
klog.Warningf("Unable to query memory limits: %+v", err)
}
req = noLimitMemory(sysLimit, containerLimit)
req = noLimitMemory(sysLimit, containerLimit, drvName)
} else {
req, err = util.CalculateSizeInMB(memString)
if err != nil {
Expand All @@ -1409,12 +1409,18 @@ func validateChangedMemoryFlags(drvName string) {
validateRequestedMemorySize(req, drvName)
}

func noLimitMemory(sysLimit int, containerLimit int) int {
func noLimitMemory(sysLimit, containerLimit int, drvName string) int {
if containerLimit != 0 {
return containerLimit
}
// Recommend 1GB to handle OS/VM overhead
return sysLimit - 1024
sysOverhead := 1024
if drvName == "virtualbox" {
// VirtualBox fully allocates all requested memory on start, it doesn't dynamically allocate when needed like other drivers
// Because of this allow more system overhead to prevent out of memory issues
sysOverhead = 1536
}
return sysLimit - sysOverhead
}

// This function validates if the --registry-mirror
Expand Down
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func getMemorySize(cmd *cobra.Command, drvName string) int {
memString := viper.GetString(memory)
var err error
if memString == constants.MaxResources {
mem = noLimitMemory(sysLimit, containerLimit)
mem = noLimitMemory(sysLimit, containerLimit, drvName)
} else {
mem, err = pkgutil.CalculateSizeInMB(memString)
if err != nil {
Expand Down