Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is memory management in different languages similar enough to transfer my knowledge?

I'm just starting to learn programming. And as of now, I know a tad bit of memory management in Objective-C. It wasn't easy learning it.

So, just out of curiosity, is the memory management employed in major languages like C, C++, Java, etc., in any way similar to what I've learned?

like image 424
r0ach Avatar asked Nov 30 '22 12:11

r0ach


2 Answers

Memory management comes in two distinct flavours: unmanaged and managed.

Unmanaged is C/C++ where the programmer is responsible for memory allocation.

Managed is like Java/.Net, where memory is allocated for you but cleaned up by the virtual machine ("garbage collected").

Within those two flavours you will find many variations.

like image 145
cletus Avatar answered Dec 05 '22 02:12

cletus


No, it can vary significantly between platforms - and even within the same platform, there can be various different options. (e.g. in C++, you can use auto pointers, a Boehm GC, etc.)

Java and .NET have mostly similar memory management, mind you.

like image 45
Jon Skeet Avatar answered Dec 05 '22 02:12

Jon Skeet