Is there any way to get the memory size/usage of a variable?
Emacs 28 adds a more fine-grained memory usage reporting command than was previously available:
** New command 'memory-report'.
This command opens a new buffer called "*Memory Report*" and gives a
summary of where Emacs is using memory currently.
One of its subroutines is memory-report-...