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

improve --heap-size-hint arg handling #48050

Merged
merged 15 commits into from
Feb 23, 2024
Merged
6 changes: 5 additions & 1 deletion src/jloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,11 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
jl_errorf("julia: invalid argument to --heap-size-hint (%s)", optarg);
break;
}
jl_options.heap_size_hint = (uint64_t)(value * multiplier);
double sz = value * multiplier;
vtjnash marked this conversation as resolved.
Show resolved Hide resolved
mbauman marked this conversation as resolved.
Show resolved Hide resolved
if (isnan(sz) || sz < 0) {
jl_errorf("julia: invalid argument to --heap-size-hint (%s)", optarg);
}
jl_options.heap_size_hint = sz < UINT64_MAX ? (uint64_t)sz : UINT64_MAX;
}
if (jl_options.heap_size_hint == 0)
jl_errorf("julia: invalid argument to --heap-size-hint without memory size specified");
Expand Down
6 changes: 5 additions & 1 deletion test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,12 @@ end
@testset "--heap-size-hint" begin
exename = `$(Base.julia_cmd())`
@test errors_not_signals(`$exename --heap-size-hint -e "exit(0)"`)
@testset "--heap-size-hint=$str" for str in ["asdf", "", "0","1.2vb","b","GB","1.2gb2","42gigabytes","5gig","2GiB","NaNt"]
@testset "--heap-size-hint=$str" for str in ["asdf","","0","1.2vb","b","GB","1.2gb2","42gigabytes","5gig","2GiB","NaNt"]
@test errors_not_signals(`$exename --heap-size-hint=$str -e "exit(0)"`)
if errors_not_signals(`$exename --heap-size-hint=$str -e "exit(0)"`)
@show str
run(`$exename --heap-size-hint=$str -e "exit(0)"`)
end
end
k = 1024
m = 1024k
Expand Down