You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the worsest scenario is that, append 1 byte repeatly.
if total buffer size finally is 1MBtye, write 1 byte one by one
then the waste memory is that ((1M-1) + 1)(1M-1) / 2 ≈ 0.5TByte, if total buffer size is N Byte, the waste memory is almost equal N^2/2,
the memory leak is scary
the best way to increse buffer size is use doule times increase,
so if total buffer size finally is 1MBtye+1, write bytes free of hands.
then the waste memory is that (1MByte-1) + 1Mbyte*2 -1(the unused memory + 1b+11b+111b+1111b+...+1M) ≈ 3MByte
the waste uint8array class instatiate calculate is the same
The text was updated successfully, but these errors were encountered:
LinboLen
changed the title
the length of the buffer should grow double times than previous buffer length
the length of the buffer should grow double times than previous
Jan 11, 2017
the worsest scenario is that, append 1 byte repeatly.
if total buffer size finally is 1MBtye, write 1 byte one by one
then the waste memory is that
((1M-1) + 1)(1M-1) / 2
≈ 0.5TByte, if total buffer size is N Byte, the waste memory is almost equal N^2/2,the memory leak is scary
the best way to increse buffer size is use doule times increase,
so if total buffer size finally is 1MBtye+1, write bytes free of hands.
then the waste memory is that
(1MByte-1) + 1Mbyte*2 -1
(the unused memory + 1b+11b+111b+1111b+...+1M) ≈ 3MBytethe waste uint8array class instatiate calculate is the same
ref: https://github.com/openjdk-mirror/jdk/blob/jdk8u/jdk8u/master/src/share/classes/java/io/ByteArrayOutputStream.java#L113
java use double times buffer size increase
The text was updated successfully, but these errors were encountered: