Following is the topic of discussion for Introduction to Programming CS201.
“Dynamic memory allocation by using pointers provides an efficient way of utilizing computer memory but such memory allocation may be problematic if not handled properly in program".
You have to support or contradict the given statement with proper justification.
A concise, coherent and to the point comment is preferred over lengthy comment having irrelevant details. Comments, posted on regular Lesson's MDB or sent through email will NOT be considered in any case. Any request about such an acceptance will not be catered.
Please Discuss here about this GDB.Thanks
Our main purpose here discussion not just Solution
We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions.
Dear Students Don’t wait for solution post your problems here and discuss ... after discussion a perfect solution will come in a result. So, Start it now, replies here give your comments according to your knowledge and understandings....
please brother explain me
what is the difference between heap and stack memory allocation.
Excellent Sir, very nice explanation..
Zulfiqar Ahmad Zakki thanks
Attention Students: You don’t need to go any other site for this assignment/GDB/Online Quiz solution, Because All discussed data of our members in this discussion are going from here to other sites (Other sites Admins posted with fake IDs at their sites :p ). You can judge this at other sites yourself. So don’t waste your precious time with different links.
there is many greatest danger like unreferenced memory, buffered memory etc
GDB solution of CS201 july 2013
The statement is true -- dynamic memory allocation is efficient and effective, and it's also very necessary. And, like anything powerful, it can be dangerous if not performed properly.
GDB solution of CS201 july 2013
There are several ways to misuse memory. First, if you're allocating for say a 20 character sting, you need to allocate 21 bytes, 42 for wide characters, to allow for a the terminating 0. If your program tries to write 25 characters to that memory, you'll overrun into some other data's memory. When you're done with the memory, if it's not freed, you can run out of available memory.
what do mean by 42 for wide characters to allow for a the termination 0
What if your program is able to use more memory whever it needs and you vulearners make a very small mistake in there? So it just keeps taking more and more and eventually runs the computer out of memory. This is called a memory leak.
Now lets say you want to free memory to prevent a leak. So you go out and free things using pointers and so on.... and you free up some memory that was already garbage collected! It has been reassigned and you free memory that is being used by another program!
The advantage is that you do not have to statically track down and map out every last bit of memory needed. You can take in large chunks of data easily and improve the flow of a program by being dynamic. This improved performance vulearners.com has allowed computers to do far more than when they were static and limited to very small address ranges
Old saying: With great power comes great responsibility. Dynamic memory is one of these cases. It is powerful and useful and if you mess up it will crash the machine.
Oh, and that is in no way a comprehensive list of things. While dynamic memory can make things more powerful, it can quickly cause them to be more problematic in other ways.
so, what's your last comment are you in support or contradict of dynamic memory allocation ?
It is a tool. Like any tool, it is great if it is used properly. And also, can be problematic when used improperly. I am not going to claim to be for or against it. I am just trying to point out why it is a complex issue that must be learned properly before being used.