Date: 2024-05-08 09:48 pm (UTC)
From: [personal profile] aklepatc
This memory is not completely lost for the lifetime of the process. It is freed/reclaimed every time the slice gets reallocated by append().

So it is only "leaked" until the next append() causes reallocation. "Normally" though, append() does not cause reallocation. So you don't know for sure when (if ever) the memory is returned to the process.

You keep truncating the buffer on the left... So you might be causing reallocation on every loop iteration? I'm not too sure TBH.

Language standard does not (precisely) specify reallocation policy. AFAIU in practice reallocation doubles capacity. But I am not too sure what the base number is: original capacity or original length. So I cannot confidently reason about how many reallocations your code would cause.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

aklepatc

May 2024

S M T W T F S
   1234
567 891011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 24th, 2025 10:58 am
Powered by Dreamwidth Studios