We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More


Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

How to Add New Discussion in Study Group ? Step By Step Guide Click Here.

Following is the topic of discussion for Introduction to Programming CS201.

GDB Topic: 
 

“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.

+ How to Follow the New Added Discussions at Your Mail Address?

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?


See Your Saved Posts Timeline

Views: 1333

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Replies to This Discussion

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.

thanks janab

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


“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.”


I do agree with this statement, pointer is a powerful feature of c++ and we all know the power can swing both sides good and evil. Pointer if used incorrectly leads to very difficult to unearth bugs which will most probably make you go wild. Every pointer is pointing to a memory location and if value is incorrect then it can lead to disasters of massive magnitude when used on the required block of code. It is actually equal to having an address of house but wrong.
Consider a scenario in banking in which any customers real account value is switched with this garbage value, he can become a millionaire or beggar in a second, or think that in a rocket launching software you use this incorrect value as launching angle and crashing the billion dollar masterpiece. 
These scenarios are just my imagination running wild but you cannot ignore the fact that they are possibility.

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


“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.”


I do agree with this statement, pointer is a powerful feature of c++ and we all know the power can swing both sides good and evil. Pointer if used incorrectly leads to very difficult to unearth bugs which will most probably make you go wild. Every pointer is pointing to a memory location and if value is incorrect then it can lead to disasters of massive magnitude when used on the required block of code. It is actually equal to having an address of house but wrong.
Consider a scenario in banking in which any customers real account value is switched with this garbage value, he can become a millionaire or beggar in a second, or think that in a rocket launching software you use this incorrect value as launching angle and crashing the billion dollar masterpiece. 
These scenarios are just my imagination running wild but you cannot ignore the fact that they are possibility.



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.

  1. what do mean by 42 for wide characters to allow for a the termination 0

    • "Strings" (which are actually arrays of characters) need a terminating value. Zero has been adopted for this, so a string is actually one byte longer than what you see. Computers started very American-centric. ASCII is an acronym for American Standard Code for Information Interchange. Originally, there were 127 characters defined, ASCII-7. After adding more characters (mostly symbols), it became ASCII-8. ASCII-8 basically became UTF-8. I've been told that the Chinese alphabet has over 29,000 characters, so that would require 16 bits, two bytes to represent. This is UTF-16. C refers to 16 bit character representation as wide characters. The 20 character "string" in the example would be 20 x 2 bytes long plus a 16-bit terminating zero, 42 bytes.



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.




RSS

Latest Activity

+Mr President updated their profile
7 minutes ago
A_Q added a discussion to the group ENG513 Language Teaching Methods
26 minutes ago
ALEENA replied to + M.Tariq Malik's discussion Site Overview | Assignment Solutions | Past Papers Solutions | VU Students Features
27 minutes ago
+ !! "AS" !! replied to + !! "AS" !!'s discussion Ghalti...
29 minutes ago
Profile IconALI RAZA, Husnain Kan, Safdar Mehmood and 25 more joined Virtual University of Pakistan
32 minutes ago
ALEENA liked + Iuuoɔǝut +'s discussion MTH401_Mid term Solved (Part I) with refrence
34 minutes ago
Shine--Ex-VUStudent liked + !! "AS" !!'s discussion Yaha Har Cheez ..
35 minutes ago
Shine--Ex-VUStudent liked +¢αяєℓєѕѕ gιяℓ's discussion Iss tasvir ko Unwan Dein :-P
38 minutes ago
ALEENA replied to ٥ دن's discussion Gunahon ki gehrai
38 minutes ago
ALEENA replied to + !! "AS" !!'s discussion Ghalti...
40 minutes ago
ALEENA replied to Siddiq khan kakar's discussion RIP
43 minutes ago
Muhammad Hamza Mehmood liked Faiza's profile
44 minutes ago
Profile IconKhan and zuha shah joined + M.Tariq Malik's group
45 minutes ago
Khan joined + M.Tariq Malik's group
46 minutes ago
Profile IconKhan and sardarni joined + M.Tariq Malik's group
48 minutes ago
ALEENA replied to +¢αяєℓєѕѕ gιяℓ's discussion Iss tasvir ko Unwan Dein :-P
51 minutes ago
zuha shah joined + M.Tariq Malik's group
52 minutes ago
zuha shah liked + M.Tariq Malik's group PSY401 Clinical Psychology
52 minutes ago
zuha shah liked + M.Tariq Malik's group MGT111 Introduction to Public Administration
52 minutes ago
Ali joined + M.Tariq Malik's group
55 minutes ago

© 2019   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service