Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » how does a constructor achieve memory management in java
Closed Thread
Old 10-26-2006, 10:47 AM   #1 (permalink)
 
Master Techie

Join Date: Mar 2004

Posts: 2,069

rookie1010

Default how does a constructor achieve memory management in java

Hello

I was trying to get to grips with Java, and i came across this statement that constructing objects has a responsibility of
memory management.
how does a constructor achieve memory management? in the context of constructors is memory management the same as memory initialisation
rookie1010 is offline  
Old 10-26-2006, 11:07 AM   #2 (permalink)
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 569

jaeusm is on a distinguished road

Default

Memory management is handled by the Java Virtual Machine (JVM), not an object's constructor. The constructor has the job of constructing or intializing the object.
jaeusm is offline  
Old 10-27-2006, 11:16 AM   #3 (permalink)
 
Master Techie

Join Date: Mar 2004

Posts: 2,069

rookie1010

Default

what is memory management anyway?

is it the assignment of RAM memory to a process, that would be a kernel level issue, correct?
rookie1010 is offline  
Old 10-27-2006, 12:42 PM   #4 (permalink)
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 569

jaeusm is on a distinguished road

Default

Quote:
is it the assignment of RAM memory to a process
In the context of this discussion, no. If you ever do any substantial C or C++ programming, you'll see that the programmer is responsible for memory management. With Java and C#, their respective runtime environments manage the memory for you. For instance, when you create a new object in Java, you don't have to worry about keeping track of a pointer and freeing the memory when you are finished. The JVM handles that (garbage collection). In a C++ program, on the other hand, you'll need to manually free the memory you allocated with each "new" statement by using the "delete" (or "free") key word. Because the JVM is in charge of the memory management, Java has no concept of pointers as far as the Java developer is concerned.
jaeusm is offline  
Old 10-28-2006, 07:07 PM   #5 (permalink)
 
Master Techie

Join Date: Mar 2004

Posts: 2,069

rookie1010

Default

oh thanks for explanation

thanks dude
rookie1010 is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On