# Questions about mlock()



## wdick (Jun 2, 2020)

Hello,

I am in the process of migrating all of our Linux systems to FreeBSD 12. So far everything looks very good and I am quite happy with my new and shiny FreeBSD systems.

The only problem that occurred is: mlock(). While I try to work around this problem, I would like to understand it. Why / how does mlock() behave differently then on Linux?

Example one: HashiCorp Vault.
There are some open tickets in their GitHub repository from the beginning of 2019, like https://github.com/hashicorp/vault/issues/6340

Second example: MongoDB 4.0.
Again MongoDB won't start with mlock() enabled. So the rc.d script disables it by default.
But there is no way to disable it for the mongo client, so it just core dumps if it needs "secure" memory.
There are closed tickets addressing this issue, but no fixes (https://jira.mongodb.org/browse/SERVER-29086).

My understanding is, that the developers of both projects are missing the information or understanding of how FreeBSD differs here from Linux and what they should do to fix the issue.

All workarounds posted in the comments for these issues are provided by application users. Which are build upon trial and error and not on the basis of really understanding the underlying problem. 

Sadly I am no C/C++ developer (and no kernel developer at all), so I thought I try it here, before diving into it myself.

If you have any ideas or insights into the implementation differences, you possible could help me and two of my favourite projects!
Thank you!

Regards,
Waldemar


----------



## wdick (Jun 2, 2020)

Ok, found my problem: https://forums.freebsd.org/threads/freebsd-11-1-zfs-using-to-much-wired-memory.64702/

So, it wasn't actually the applications, but my understanding of vm.max_wired and ZFS of using a lot of wired memory.


----------

