Is it possible to create a new Date() object to get the current date, and then later, after a certain period of time, reuse the same Date() object to get the new current time?
It appears that you have to create a new Date object everytime you want the current date/time.
In my particular application I’m wanting to run an animation and for every single frame of the animation I need to aquire the current time. So creating a new Date object every single frame (potentially for 1000’s of frames?) is just going to boost memory usage over time.
Any clues on this one?
Unless you’re storing them separately, your date objects are garbage collected automatically. Moreover you can create store the current date to the same variable every iteration and not have to worry about memory blooming.
For example:
You do not use more and more memory in this case because the old date will be garbage-collected after it has been overwritten.