Too many allocations, incorrect data representation
Heavy usage of reflection or strings
Using globals
Orphaned, never-ending goroutines
利用golang实现blockchain
Since in Go there is no simple way to analyze the full core dump, getting to the roots of an object that does not get GC-ed is difficult.
It is more important to build the system in a way that avoids premature optimizations and enables you to perform them later on as the code matures, rather than over engineer it from the get-go.
Go has several built in profiles for us to use in common cases:
goroutine — stack traces of all current goroutines
heap — a sampling of memory allocations of live objects
allocs — a sampling of all past memory allocations
threadcreate — stack traces that led to the creation of new OS threads
block — stack traces that led to blocking on synchronization primitives
mutex — stack traces of holders of contended mutexes
flat means that the memory allocated by this function and is held by that function
cum means that the memory was allocated by this function or function that it called down the stack
understanding that when we serialize data, meaning that we allocate memory to structs and primitive objects (int, string), it is never released.在数据序列化过城中,相关的memory还依旧被保存着