Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identifying where memory allocation is happening in core

This might be a silly question or too open-ended, but what do I look for in GHC core output to understand where memory allocations are happening? My motivation is to better understand how to optimize code like this, or e.g. to try to avoid preemption during critical sections in concurrent code.

like image 377
jberryman Avatar asked Apr 11 '14 04:04

jberryman


People also ask

How does memory allocation happen in C#?

Stack and Heap The Common Language Runtime (CLR) allocates memory for objects in these parts. Stack is a simple LIFO(last-in-first-out) structure. Variables allocated on the stack are stored directly to the memory and access to this memory is very fast, and its allocation is done when the program is compiled.

How do I find a memory leak in go?

pprof and flame graphs are pretty useful to analyze application memory leaks. A continuous profiler can really help you look at multiple snapshots of the profile and quickly figure out the cause of leaks. Cloud profiler is definitely a handy tool for GCP workloads.

How do you analyze Pprof?

The only thing you need to do is import net/http/pprof and start an http listener. The pprof package will register its endpoints right below the web server root at /debug/pprof. In order to analyze the currently used memory, just select the inuse indices (bytes or object counts):


1 Answers

lets is typically where this happens, assuming the variable being bounds id not of kind # (i.e. a let-bound Int# doesn't cause allocation.) However, it's really STG which defines exactly where it happens.

like image 141
tibbe Avatar answered Oct 11 '22 22:10

tibbe