+ 1

How to learn memory management

I am learning C but cannot think of how to actually implement memory management in real life situations. If I finish the Sololearn C course and then study Data Stuctures and Algorithms, will Data stuctures and Algorithms help me to better understand how to apply the knowledge about things like pointers and memory management that I learned in the C course? Any feedback would be greatly appreciated, thank you

14th Mar 2022, 1:12 PM
Jermainne Espinoza
10 Réponses
+ 4
My first language(s) were BASIC and TurboPascal on a Commodore C16 and Intel 8086 😅 I added C rather late... I cannot recommend C# as a language paving a way towards C. It is fundamentally a different concept and following a different paradigm. It largely depends on where you are headed. You don't need C to learn C#, and neither the other way around. Learning C will teach you a lot about the inner workings of a PC. C is still the lingua franca on UNIX systems. But if you want to go for development for a Windows environment, C is practically not used, except for perhaps very special niche programs, experiments, and perhaps driver libraries. But I am not really an expert in that area.
14th Mar 2022, 1:55 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 3
Yes, I think so. Data structures will certainly require you to implement a lot of dynamic resource allocation and management. I am not sure if it is of any help if you go in largely unprepared. That is to say, I cannot estimate what skills are already required before you start implementing data structures in C. Perhaps someone else can shed some light on it from personal experience :)
14th Mar 2022, 1:28 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 3
You're welcome :). Incidentally, I have a code here implementing a kind of dynamically sized string. You may have a look at it if you like... https://code.sololearn.com/c1WDri42R5LO
14th Mar 2022, 1:31 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 2
Thank you
14th Mar 2022, 1:29 PM
Jermainne Espinoza
+ 2
Thank you so much. Also, if i may ask you, I really wanted to learn C being that it is a foundational/fundamental language but i feel like maybe i should start with an easier language like C# for instance and then after i have mastered C# i can move to C. Do you think that is a good idea? What was the first language that you learned? Any feedback would greatly appreciated, thank you
14th Mar 2022, 1:38 PM
Jermainne Espinoza
+ 1
I don't think SoloLearn is enough to actually understand memory. one of the most important skills in programming is debugging and it is not easy to teach in Sololearn with practice. you can get a better understanding of memory, by writing a simple program and load it into a debugger, then you can inspect the memory and how it's used by your program. (example of debuggers: GDB, WinDbg, Radare2....) most of IDEs come with a debugger to step through the code and examine memory(stack, heap) , cpu registers... . in short try to learn how to use a debugger. there are many, depending on what operating system you are using. you can even go deeper to assembly to really understand how it works.
14th Mar 2022, 1:57 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
When you're using C, you're actually doing memory management of your program using pointers. C is a language very close to Assembly Language (actually, you can call Assembly language procedures in C), it originally was made to replace the ASM code of the UNIX OS. If you will be doing Kernel Development (here you will do a lot of memory management), you will use memory management for the whole System when you need to allocate memory for a process for example. If you're doing algorithms and data structures, you will use stack memory management and heap memory management (using malloc) for optimizing your programs (like passing for reference using pointers) You will apply a lot of Real-life C when you're working with OS Development or Embbeded System Development, or maybe desktop application Development (even Malware Development and Reverse Engineering). And for all of this (except desktop app dev) you will need to learn Assembly Language for the processor you're working at
15th Mar 2022, 12:31 PM
__xr00w
__xr00w - avatar
0
👍
14th Mar 2022, 1:32 PM
Jermainne Espinoza
0
Thank you, so, would tou suggest i start with C or an easier language?
14th Mar 2022, 2:12 PM
Jermainne Espinoza