2009年2月12日星期四

the memory management in C

Although I'm not very familiar with the memory management in C and i also don't understand the working principle, i have written a lot of code using pointer and data struct or union. Therefore i found something must be notices. for example, the memory allocated must be free when they finish their job, otherwise they will still in used until the program exit.

I know C give a lot of freedom for programmer to control how to use the memory. The pointer in C is very useful. But i think the memory management in C is semi-automatic which means the compiler will just do half of the job, another left to user. To be honest, i do not like this working style. Of course programmer can control a lot but not every things, some half of the job is still done by the compiler not programmer. Programmer can not access all of the memory because of security reason, but coding in totally auto-way sometimes will case problem. That's why i said the memory management in C is semi-automatic.

Howevery, I like programing in C. I think C style is colse to the working principle of the computer. Since I using C, I understand more about how the computer work. Every time i got a problem, i will spend lots of time to study why it happen, what case the problem and how to avoid it. In programing, memory is very important because all algorithm base on data which was saved in memory. The semi-automatic memory management give me more freedom in it. As I said before, i don't like semi-automatic. In fact i like total control by my self like assembly and i hate totally automatic controling by the some other things(compiler). Assembly is hard to use so i just use C and half is enought, it can done a lot!
發佈留言

熱門文章