-
Notifications
You must be signed in to change notification settings - Fork 242
Memory allocation pitfalls
Mamy Ratsimbazafy edited this page Aug 27, 2020
·
1 revision
There are a couple of common pitfalls that unnecessary allocates memory and may seriously impact performance by:
- introducing GC latency
- increasing memory fragmentation
- introducing unnecessary indirection
- introducing unnecesary instruction
- preventing compiler optimizations
Example: https://github.com/status-im/nim-beacon-chain/pull/1573
Those common ways are:
-
[]
slicing instead of toOpenArray - Iterating with implicit
items
on an array/array fields. This is solved in Nim devel (https://github.com/nim-lang/Nim/issues/14421), but not in the 1.2.x branch that we target.