I'm not sure what you mean by "hard on the memory" and I doubt that making those variables global is worthwhile . Even if there is some slight performance boost (it might translate to a few less assembly instructions, I guess), you now have three global variables that stay in memory as long as the application is running. And besides that, they retain their values each time the function is called. If someone needs that, they can always use static variables.
It wouldn't be as hard on the memory.
The reason for this is because if the way you have it, it would have to declare all three of those vars every time the window calls that function. Which would be a lot of times.