membrane

oskarkv 2026-05-07T03:44:38.786259Z

I'm making a game using membrane, and every frame I am creating new elements. I noticed I had a memory leak, and I tracked it down to the memoize in membrane.ui/bounds. Is it really a good idea to memoize there?

oskarkv 2026-05-08T10:58:35.604959Z

Oh, weakhashmap sounds like a good idea. I will try it.

phronmophobic 2026-05-07T11:16:34.504909Z

caching membrane.ui/bounds is very important for performance for typical UIs. I've cleaned up some memory leaks on master. bounds now uses a threadlocal weakhashmap, https://github.com/phronmophobic/membrane/blob/93835080c35b86409e6a9ef416ef0e3eae353ac6/src/membrane/ui.cljc#L17.

phronmophobic 2026-05-07T11:17:19.130689Z

I've been running this version locally for a few months and it seems to be working well.

phronmophobic 2026-05-07T11:20:15.347349Z

There's a bunch of different caches. There are also lots of different caching strategies with various tradeoffs. Eventually, I'd like to have some way to simplify the caching so different use cases can make different decisions.