aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/binary_module_SUITE.erl
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-08-08 10:06:25 +0200
committerJohn Högberg <[email protected]>2019-08-09 14:29:39 +0200
commit9f73f98ad6ddf70d30dfc0a1daf7c992dcc5061a (patch)
treedb0771bf4e7e323b4b18d4a3c4b1d5d71ec960a5 /lib/stdlib/test/binary_module_SUITE.erl
parent83cd52cf585e37f65f956f18464b8cec98dde469 (diff)
downloadotp-9f73f98ad6ddf70d30dfc0a1daf7c992dcc5061a.tar.gz
otp-9f73f98ad6ddf70d30dfc0a1daf7c992dcc5061a.tar.bz2
otp-9f73f98ad6ddf70d30dfc0a1daf7c992dcc5061a.zip
erts: Create heap binaries in bs_get_binary2
ErlSubBin is a large struct that often dwarfs the region of memory it points at, and it's common for them to refer to a ProcBin which must be kept around as long as the SubBin lives, using up even more heap space and keeping the referenced binary alive regardless of how small the sub-binary is.
Diffstat (limited to 'lib/stdlib/test/binary_module_SUITE.erl')
-rw-r--r--lib/stdlib/test/binary_module_SUITE.erl32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/stdlib/test/binary_module_SUITE.erl b/lib/stdlib/test/binary_module_SUITE.erl
index 9b2033ec4a..be8ab3b98e 100644
--- a/lib/stdlib/test/binary_module_SUITE.erl
+++ b/lib/stdlib/test/binary_module_SUITE.erl
@@ -716,22 +716,22 @@ referenced(Config) when is_list(Config) ->
badarg = ?MASK_ERROR(binary:referenced_byte_size(apa)),
badarg = ?MASK_ERROR(binary:referenced_byte_size({})),
badarg = ?MASK_ERROR(binary:referenced_byte_size(1)),
- A = <<1,2,3>>,
- B = binary:copy(A,1000),
- 3 = binary:referenced_byte_size(A),
- 3000 = binary:referenced_byte_size(B),
- <<_:8,C:2/binary>> = A,
- 3 = binary:referenced_byte_size(C),
- 2 = binary:referenced_byte_size(binary:copy(C)),
- <<_:7,D:2/binary,_:1>> = A,
- 2 = binary:referenced_byte_size(binary:copy(D)),
- 3 = binary:referenced_byte_size(D),
- <<_:8,E:2/binary,_/binary>> = B,
- 3000 = binary:referenced_byte_size(E),
- 2 = binary:referenced_byte_size(binary:copy(E)),
- <<_:7,F:2/binary,_:1,_/binary>> = B,
- 2 = binary:referenced_byte_size(binary:copy(F)),
- 3000 = binary:referenced_byte_size(F),
+ A = <<0:(1024 * 8)>>,
+ B = binary:copy(A, 1000),
+ 1024 = binary:referenced_byte_size(A),
+ 1024000 = binary:referenced_byte_size(B),
+ <<_:8,C:1023/binary>> = A,
+ 1024 = binary:referenced_byte_size(C),
+ 1023 = binary:referenced_byte_size(binary:copy(C)),
+ <<_:7,D:1023/binary,_:1>> = A,
+ 1023 = binary:referenced_byte_size(binary:copy(D)),
+ 1024 = binary:referenced_byte_size(D),
+ <<_:8,E:128/binary,_/binary>> = B,
+ 1024000 = binary:referenced_byte_size(E),
+ 128 = binary:referenced_byte_size(binary:copy(E)),
+ <<_:7,F:128/binary,_:1,_/binary>> = B,
+ 128 = binary:referenced_byte_size(binary:copy(F)),
+ 1024000 = binary:referenced_byte_size(F),
ok.