@@ -1219,13 +1219,9 @@ end
1219
1219
end
1220
1220
1221
1221
@testset " hard heap limit" begin
1222
- # Set the hard heap limit to 100MB, try to allocate an array of 200MB
1223
- # and assert that the process is aborted, by checking the exit code.
1224
- cmd = ` $(Base. julia_cmd ()) --startup-file=no --hard-heap-limit=100M -e "a = Array{UInt8}(undef, 200*1024*1024); GC.gc()"`
1225
- p = open (pipeline (cmd, stderr = devnull , stdout = devnull ))
1226
- exitcode = wait (p)
1227
- # The process should be aborted with an error code
1228
- @test exitcode != 0
1222
+ cmd = ` $(Base. julia_cmd ()) --hard-heap-limit=30M -E "mutable struct ListNode; v::Int64; next::Union{ListNode, Nothing}; end\n
1223
+ l = ListNode(0, nothing); while true; l = ListNode(0, l); end"`
1224
+ @test ! success (cmd)
1229
1225
end
1230
1226
end
1231
1227
@@ -1272,27 +1268,24 @@ end
1272
1268
@testset " --hard-heap-limit=$str " for str in [" asdf" ," " ," 0" ," 1.2vb" ," b" ," GB" ," 2.5GB̂" ," 1.2gb2" ," 42gigabytes" ," 5gig" ," 2GiB" ," NaNt" ]
1273
1269
@test errors_not_signals (` $exename --hard-heap-limit=$str -e "exit(0)"` )
1274
1270
end
1275
- k = 1024
1276
- m = 1024 k
1277
- g = 1024 m
1278
- t = 1024 g
1279
- # Express one hundred megabytes as 100MB, 100m, 100e6, etc.
1271
+ k = UInt64 (1 ) << 10
1272
+ m = UInt64 (1 ) << 20
1273
+ g = UInt64 (1 ) << 30
1274
+ t = UInt64 (1 ) << 40
1280
1275
one_hundred_mb_strs_and_vals = [
1281
1276
(" 100000000" , 100000000 ), (" 1e8" , 1e8 ), (" 100MB" , 100 m), (" 100m" , 100 m), (" 1e5kB" , 1e5 k),
1282
1277
]
1283
1278
@testset " --hard-heap-limit=$str " for (str, val) in one_hundred_mb_strs_and_vals
1284
1279
@test parse (UInt64,read (` $exename --hard-heap-limit=$str -E "Base.JLOptions().hard_heap_limit"` , String)) == val
1285
1280
end
1286
- # Express two and a half gigabytes as 2.5g, 2.5GB, etc.
1287
1281
two_and_a_half_gigabytes_strs_and_vals = [
1288
1282
(" 2500000000" , 2500000000 ), (" 2.5e9" , 2.5e9 ), (" 2.5g" , 2.5 g), (" 2.5GB" , 2.5 g), (" 2.5e6mB" , 2.5e6 m),
1289
1283
]
1290
1284
@testset " --hard-heap-limit=$str " for (str, val) in two_and_a_half_gigabytes_strs_and_vals
1291
1285
@test parse (UInt64,read (` $exename --hard-heap-limit=$str -E "Base.JLOptions().hard_heap_limit"` , String)) == val
1292
1286
end
1293
- # Express one terabyte as 1TB, 1e12, etc.
1294
1287
one_terabyte_strs_and_vals = [
1295
- (" 1000000000000 " , 1000000000000 ), ( " 1e12 " , 1e12 ), ( " 1TB" , 1 t), (" 1e9gB " , 1e9 g ),
1288
+ (" 1TB" , 1 t), (" 1024GB " , 1 t ),
1296
1289
]
1297
1290
@testset " --hard-heap-limit=$str " for (str, val) in one_terabyte_strs_and_vals
1298
1291
@test parse (UInt64,read (` $exename --hard-heap-limit=$str -E "Base.JLOptions().hard_heap_limit"` , String)) == val
@@ -1305,27 +1298,24 @@ end
1305
1298
@testset " --heap-target-increment=$str " for str in [" asdf" ," " ," 0" ," 1.2vb" ," b" ," GB" ," 2.5GB̂" ," 1.2gb2" ," 42gigabytes" ," 5gig" ," 2GiB" ," NaNt" ]
1306
1299
@test errors_not_signals (` $exename --heap-target-increment=$str -e "exit(0)"` )
1307
1300
end
1308
- k = 1024
1309
- m = 1024 k
1310
- g = 1024 m
1311
- t = 1024 g
1312
- # Express one hundred megabytes as 100MB, 100m, 100e6, etc.
1301
+ k = UInt64 (1 ) << 10
1302
+ m = UInt64 (1 ) << 20
1303
+ g = UInt64 (1 ) << 30
1304
+ t = UInt64 (1 ) << 40
1313
1305
one_hundred_mb_strs_and_vals = [
1314
1306
(" 100000000" , 100000000 ), (" 1e8" , 1e8 ), (" 100MB" , 100 m), (" 100m" , 100 m), (" 1e5kB" , 1e5 k),
1315
1307
]
1316
1308
@testset " --heap-target-increment=$str " for (str, val) in one_hundred_mb_strs_and_vals
1317
1309
@test parse (UInt64,read (` $exename --heap-target-increment=$str -E "Base.JLOptions().heap_target_increment"` , String)) == val
1318
1310
end
1319
- # Express two and a half gigabytes as 2.5g, 2.5GB, etc.
1320
1311
two_and_a_half_gigabytes_strs_and_vals = [
1321
1312
(" 2500000000" , 2500000000 ), (" 2.5e9" , 2.5e9 ), (" 2.5g" , 2.5 g), (" 2.5GB" , 2.5 g), (" 2.5e6mB" , 2.5e6 m),
1322
1313
]
1323
1314
@testset " --heap-target-increment=$str " for (str, val) in two_and_a_half_gigabytes_strs_and_vals
1324
1315
@test parse (UInt64,read (` $exename --heap-target-increment=$str -E "Base.JLOptions().heap_target_increment"` , String)) == val
1325
1316
end
1326
- # Express one terabyte as 1TB, 1e12, etc.
1327
1317
one_terabyte_strs_and_vals = [
1328
- (" 1000000000000 " , 1000000000000 ), ( " 1e12 " , 1e12 ), ( " 1TB" , 1 t), (" 1e9gB " , 1e9 g ),
1318
+ (" 1TB" , 1 t), (" 1024GB " , 1 t ),
1329
1319
]
1330
1320
@testset " --heap-target-increment=$str " for (str, val) in one_terabyte_strs_and_vals
1331
1321
@test parse (UInt64,read (` $exename --heap-target-increment=$str -E "Base.JLOptions().heap_target_increment"` , String)) == val
0 commit comments