Hi. Let's say I have the following method:
void createNewObject() {
MyClass myObject = new MyClass();
}
If I call this method 1000 times, how many instances of MyClass will be left in my program's memory by the time all calls have been made? 1000, 1, or 0?
What I'm asking is - can creating new instances of objects inside frequently called methods lead to consequences such as memory leaks (in which case it's better to use a static object)?