Just stumbled upon this post. I just added your scripts to my Array start and stop to add/remove a cache device to my ZFS pool - not array. Unraid cannot do this natively, I guess. And I don't want to confuse Unraid with its disk management.
ZFS itself does not use much memory, but it tries to cache a lot. And the cache eats memory. But hey, why don't you wanna have unused memory?