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

ϝ ι ყ α replied to + "αяsαℓ " Ќąƶµяɨ •"'s discussion Happy Marriage to "Zee" & " Nomi weds Noor"....!
17 minutes ago
Aiman posted a status
"Hello students I am new please tell me their is any student of Bs Psychology I have a problem to make Isl201 assignment please help me"
20 minutes ago
Scorpio liked +¢αяєℓєѕѕ gιяℓ's discussion Shadi Ho Rhi Hai Alhamdulillah.......... (^__^)!
22 minutes ago
Profile IconMuhammad ishfaq, Muhammad Tazeem, Muhammad Tazeem and 28 more joined Virtual University of Pakistan
27 minutes ago
Sidra Mustafa replied to + M.Tariq Malik's discussion MGT610 Business Ethics GDB Fall 2019 Solution & Discussion in the group MGT610 Business Ethics
37 minutes ago
Sidra Mustafa joined + M.Tariq Malik's group
38 minutes ago
Imran Khan replied to + M.Tariq Malik's discussion MTH601 Assignment No 01 Fall 2019 Solution & Discussion in the group MTH601 Operations Research
46 minutes ago
Profile IconImran Khan, Hashim and Aakash Ahmed joined + M.Tariq Malik's group
46 minutes ago
+ ! ! ! ! Mehαr Mαh꧂ replied to + M.Tariq Malik's discussion MGT201 Financial Management GDB Fall 2019 Solution & Discussion Last Date: 22-11-2019 in the group MGT201 Financial Management
47 minutes ago
+ ! ! ! ! Mehαr Mαh꧂ liked + M.Tariq Malik's discussion MGT201 Financial Management GDB Fall 2019 Solution & Discussion Last Date: 22-11-2019
48 minutes ago
+"Khwab Zaadi"+ liked + M.Tariq Malik's discussion MTH501 Assignment No 01 Fall 2019 Solution & Discussion Due Date: 19-11-2019
55 minutes ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MGT201 Financial Management GDB Fall 2019 Solution & Discussion Last Date: 22-11-2019 in the group MGT201 Financial Management
1 hour ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MGT201 Financial Management GDB Fall 2019 Solution & Discussion Last Date: 22-11-2019 in the group MGT201 Financial Management
1 hour ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MGT201 Financial Management GDB Fall 2019 Solution & Discussion Last Date: 22-11-2019 in the group MGT201 Financial Management
1 hour ago
Profile IconAmna Imran and Nisha Khan joined + M.Tariq Malik's group
1 hour ago
+ ! ! ! ! Mehαr Mαh꧂ replied to +¢αяєℓєѕѕ gιяℓ's discussion Shadi Ho Rhi Hai Alhamdulillah.......... (^__^)!
1 hour ago
UMER UMER posted a discussion
1 hour ago
+ ! ! ! ! Mehαr Mαh꧂ replied to +***piya o ry piya***+'s discussion eng201
1 hour ago
UMER UMER added a discussion to the group MGT101 Financial Accounting
1 hour ago
Profile IconUMER UMER and Nisha Khan joined + M.Tariq Malik's group
1 hour ago

Today Top Members 

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

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