this post was submitted on 15 Oct 2024
6 points (100.0% liked)

Golang

2187 readers
8 users here now

This is a community dedicated to the go programming language.

Useful Links:

Rules:

founded 1 year ago
MODERATORS
 

I'm fairly new to go and I've recently migrated a in-memory cache from node to go for concurrency improvements, but the memory usage difference between the two are huge. I've tried to read up on the map memory model in go but haven't been able to find a reason for the difference. I can't see that I'm doing anything special, so I'm looking for guidance here.

The documents that are stored are around 8 KB in size as a JSON file. In node the memory usage for 50000 documents stored as objects is 1,5 GB, and for go maps it is 10 GB.

To me, this doesn't seem reasonable but I can't find the source of the difference. Could anyone here give their take on this?

top 1 comments
sorted by: hot top controversial new old
[–] nemith 4 points 2 hours ago

How are you measuring memory storage size? Are you sure you are looking as resident memory size and not just the virtual memory size?

Actual storage of the structures should be nothing. Interfaces are "fat pointers" but that should really just be an extra word which node would have at least that if not more.

My guess is that if you are looking at virtual memory that more memory/garbage is produced in PARSING and not storing and that the virtual memory size allocated is high even after garbage collection but RSS should be different.