Question about memory allocation
Okay so when you create an object (other than int, byte, etc) the pointer is stored in stack, and actual object is stored in heap.
You create new object and new pointer is created in stack and object itself in heap.
Now when you call a method on object lets say with two int parameters, two ints are being stored in stack along with other local variables. Then you call same method on other and other method. So in stack you have two pointers to objects, and six its because of 3 methods that were called.
When methods are done doing their job, their local variables are deleted from stack. So if two methods finished their job and 3rd one is still working, you call method on an object again where does it put local variables for called method? Above last called method variables or in free space with highest address?
Quote:
method locals are here cause method is not done yet
method call locals were here
method call locals were here
pointer2
pointer1
Or does garbage collector takes care of that and decides where to put vars?
P.S. This isn't related to any specific language but more to managed languages overall
Re: Question about memory allocation
You're talking about multithreading? In single thread it would be done all 1 after the other, so it would be method call 1 start then end then method call 2 start then end
there's no "finish while the other is still working" in single thread
I think I don't understand 100% What you're trying to say
Re: Question about memory allocation
Quote:
Originally Posted by
Jolin88
You're talking about multithreading? In single thread it would be done all 1 after the other, so it would be method call 1 start then end then method call 2 start then end
there's no "finish while the other is still working" in single thread
I think I don't understand 100% What you're trying to say
Yes, I was talking about multithreaded application. Should of mentioned that before.