[lug] Go and Garbage Collection
BC
bcarr at purgatoire.org
Thu Feb 22 07:16:09 MST 2018
On 2/22/2018 12:26 AM, Zan Lynx wrote:
>
>> I grew up in the era when 4k of RAM was a lot. But now... A
>> trifling in the big scheme of things.
>
> Well, it starts to add up. The situation I saw was a toy program I
> wrote that did something you can do with Awk, really. Read a big log
> file, maybe a few hundred megabytes? And store counts of how often
> words in field 6 appeared. And at the end output the list of words
> and counts.
>
> It used a LOT more memory than I expected and when I profiled it I
> realized that when I thought I was being clever by storing byte
> slices, I had actually prevented the garbage collector from
> collecting any of the file buffers. I just changed it to store
> regular strings instead, which Go copies out of byte slices and the
> problem went away.
Oooops, guilty here too. I will store this tidbit away for future
reference. Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20180222/de91248d/attachment.html>
More information about the LUG
mailing list