Comment by leni536
I think it would be probably best to handle it like real time audio, 8kHz is not far off anyway. Just collect mouse sensor data at a fixed sampling rate into a ring buffer, and don't try to have a separate complex object for each sample.
That would take care of the memory issue. It would need a way to tell the kernel to not send wm_* messages about it and a way to give the kernel a buffer to hold that data. However, you still have the overhead of processing the 'events' though or keeping up with the buffer.
It occurs to me that it may be possible to disable the wm messages. There is probably a callback hook location. Set that to 0 and it would probably not send anything. But that is just a guess and I would have to dig around in the docs to see if it is there. This indicates it is possible https://stackoverflow.com/questions/57008742/how-to-discard-... Then it would be up to you to use one of the other raw APIs to find out what is going on. https://learn.microsoft.com/en-us/windows/win32/winmsg/mouse... https://learn.microsoft.com/en-us/windows/win32/winmsg/about...