Examples of Using Hibernate with GenServer?

I’m trying to understand how hibernate works and how I can log when a process enters and exits hibernation but I am not having much luck finding a working example. I wrote this based on the documentation and it looked like it would work, but it doesn’t seem so.

On github I found a few examples like this, but that seems like it is just sending a message named :hibernate on an interval, not actually hibernating?

As far as I remember there is no way to get any log, unless you manually log that you hibernate right now.

Other than that, there is not much behind hibernation, it mainly forces a GC and then yields the process such that another process gets CPU time.

Process hibernation greatly compacts the process but you pay for it with CPU time. Its goal is to be used on processes which seldom do work but you need them to be there.

5 Likes