Be more specific with your question:
Java: deallocation is always automatic
C++: objects allocated with new have to be released with delete
In C++, memory management for linked lists typically involves using new to allocate memory for each node and delete to deallocate that memory when nodes are no longer needed. When creating a linked list, each node is dynamically allocated using new, which returns a pointer to the allocated memory. To avoid memory leaks, it's crucial to traverse the list and use delete on each node before the list goes out of scope or is destroyed. Properly managing memory ensures that resources are freed, preventing memory leaks and ensuring efficient memory use.
To instantiate a object, we use the new keyword in Java, which creates an object in memory.
New and delete are akin to malloc and free, respectively, in C. Although both malloc and free are still available in C++ (for backward compatibility and interoperability with C-style code), the new and delete operators are much simpler to use because the allocation and deallocation of all dynamic memory consumed by an object is handled by the object's own constructors and destructors. Thus there is no need to calculate how much memory to allocate; the new operator can work that out all by itself, based upon the class of object being instantiated, and the object itself can allocate/deallocate any additional dynamic memory as and when it actually requires it. This mechanism of construction/destruction allows highly complex dynamic objects and object hierarchies to be instantiated at will with just a single call to the new operator. Each object takes care of itself (as do all embedded objects and/or base classes of the object), thus all the programmer has to do is instantiate and delete an object as and when required.
In Java, you cannot directly access the memory address of an object, as Java abstracts memory management away from the programmer. However, you can use the System.identityHashCode(Object obj) method to obtain a hash code that represents the object's identity, which is often based on its memory address. Alternatively, you can use the Object class's toString() method, which typically returns a string that includes the class name and the hash code, giving a rough indication of the object's identity. Remember that these methods do not provide an actual memory address but rather a representation of the object's identity.
congugative memory allocation ,is use to array
Delete keyword
In C++, memory management for linked lists typically involves using new to allocate memory for each node and delete to deallocate that memory when nodes are no longer needed. When creating a linked list, each node is dynamically allocated using new, which returns a pointer to the allocated memory. To avoid memory leaks, it's crucial to traverse the list and use delete on each node before the list goes out of scope or is destroyed. Properly managing memory ensures that resources are freed, preventing memory leaks and ensuring efficient memory use.
To instantiate a object, we use the new keyword in Java, which creates an object in memory.
I think you're referring to the C/C++ concept of "dangling pointers." This is when you allocate some memory to a pointer, then deallocate that memory, but don't change the pointer. This causes any attempted use of the pointer to return an unused memory address. There is no such concept in Java, since the programmer has little to no control over how memory is allocated or freed. The closest thing I can think of is if you're using a class such as a Reader, in which you can close the object (Reader.close()) and then still have a reference to it. But in this case (and other similar cases) attempting to use the Reader further will result in an IOException being thrown.
New and delete are akin to malloc and free, respectively, in C. Although both malloc and free are still available in C++ (for backward compatibility and interoperability with C-style code), the new and delete operators are much simpler to use because the allocation and deallocation of all dynamic memory consumed by an object is handled by the object's own constructors and destructors. Thus there is no need to calculate how much memory to allocate; the new operator can work that out all by itself, based upon the class of object being instantiated, and the object itself can allocate/deallocate any additional dynamic memory as and when it actually requires it. This mechanism of construction/destruction allows highly complex dynamic objects and object hierarchies to be instantiated at will with just a single call to the new operator. Each object takes care of itself (as do all embedded objects and/or base classes of the object), thus all the programmer has to do is instantiate and delete an object as and when required.
In Java, you cannot directly access the memory address of an object, as Java abstracts memory management away from the programmer. However, you can use the System.identityHashCode(Object obj) method to obtain a hash code that represents the object's identity, which is often based on its memory address. Alternatively, you can use the Object class's toString() method, which typically returns a string that includes the class name and the hash code, giving a rough indication of the object's identity. Remember that these methods do not provide an actual memory address but rather a representation of the object's identity.
You can use it for virtual memory,but you need memory still.
No the memory is built in but you need a sim card
No you need the memory card
The SONY PSP doesn't necessarily need a Memory Card to function. And by function i mean to play a game or use the Internet but up to now SONY PSP's are sold with no internal memory which means if you want to have Pictures, Videos, Music, and save game data you need to have a memory card. So basically you need the memory card if you want to use the PSP to its intended use.
No need to use usb flash memory to download quick books.
The driver software will need to be installed to use your memory card software.