runtime: add used_memory() implementation for FreeBSD#24909
Conversation
|
Connected to Huly®: V_0.6-23378 |
|
I propose using It is not ideal (since it does not shrink, when memory is freed), but it is still better than returning 0 or error, and will probably compile fine. |
|
I initially used getrusage but it didn't look like it was working properly. I'll give it another try. |
|
I have a version that does produce this:
getrusage behaves weirdly indeed - it sometimes returns 0 in ru_maxrss, and sometimes the reported size does not grow, even after allocation and writing was done 🤔 edit: forgot the link to the change - spytheman@43e1fb9 |
|
It's rather late and I have a ton of work to do tomorrow at my day job. I'll look into what is going on with getrusage after I finish work tomorrow. |
|
I can push the tcc fix and merge the PR, to make the test pass on freebsd if you want, for now? |
|
Go ahead and apply your fix. |
* master: (22 commits) runtime: add used_memory() implementation for FreeBSD (vlang#24909) decoder2: fix checking and decoding of escape characters (fix vlang#24834) (vlang#24915) runtime: add note for the availability of the used_memory implementation (vlang#24913) compress,compress.gzip: add decompress_with_callback API (vlang#24904) markused: remove `@[markused]` from option and result fns (vlang#24900) ast: fix arch loongarch64 comptime support (fix vlang#24906) (vlang#24907) cgen: use alias `next` method if defined in `for x in iterator {` (vlang#24905) ci: cleanup produced executables after manually running `v ci/linux_ci.vsh` (vlang#24902) ci: skip checking vlib/datatypes/lockfree/ringbuffer_test.v on the gcc-windows job for now runtime: reduce allocations done in runtime.used_memory/0 on linux (vlang#24901) os: fix windows get_error_msg() leak (vlang#24899) runtime: add used_memory() (vlang#24897) ci: add `-prealloc` self compilation checks on more platforms (vlang#24891) cgen: allow alias types to be iterated if parent type has `next` method (fix vlang#24890) (vlang#24894) markused: whitelist `_option_none` too (fix vlang#24862) (vlang#24885) markused: fix mark for array init from sumtype (fix vlang#24887) (vlang#24889) cgen: add a `__closure_init` call for sokol/gg programs on android as well (vlang#24892) builtin,cgen,markused: add struct @[aligned] support for structs allocated on the heap too (vlang#24886) math.big: fix toom-cook 3-way multiplication (vlang#24888) x.json2.decoder2: fix option decode (fix vlang#24861) (vlang#24881) ...

Adding a FreeBSD implementation of used_memory() so that the vlib/runtime/used_memory_test.v passes.