We have been working very hard since 2009 to facilitate in your learning Read More. We can't keep up without your support. Donate Now.

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

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

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


+ 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)


Views: 1924

Replies to This Discussion

o kuch tou Ans 2 Allah k bNdou ????

Dynamic Memory Allocation 
Memory allocated "on the fly" during run time
dynamically allocated space usually placed in a program segment known as the heap or the free store
Exact amount of space or number of items does not have to be known by the compiler in advance.
For dynamic memory allocation, pointers are crucial

Just idea

Efficiency is measured in two ways:


1. Time: how long does the algorithm take to complete.
2. Space: how much working memory (typically RAM) is needed by the algorithm. This has two aspects: the amount of memory needed by the code, and the amount of memory needed for the data on which the code operates.

Dynamic memory allocation beats in both task the design time memory allocation.

Dynamic Memory Allocation
Allocating memory
There are two ways that memory gets allocated for data storage:
1.Compile Time (or static) Allocation 
   Memory for named variables is allocated by the compiler
   Exact size and type of storage must be known at compile time
   For standard array declarations, this is why the size has to be constant
2.Dynamic Memory Allocation 
  Memory allocated "on the fly" during run time
  dynamically allocated space usually placed in a program segment known as the heap or the free store
  Exact amount of space or number of items does not have to be known by the compiler in advance.
  For dynamic memory allocation, pointers are crucial

Dynamic Memory Allocation

Dynamic memory allocation is a process that allows us to do exactly what we're looking to do above, to allocate memory while our program is running, as opposed to telling the computer exactly how much we'll need (and for what) ahead of time.


With dynamic memory allocation, while the program is running, the program requests more memory from the computer. If there's enough memory available, the computer will grant the program the right to use the amount it requests.

when you use a pointer it directly points to a distinct memory address..it increases efficiency of system because when you use arrays, etc and other data types. they just allocate the memory randomly,i.e there is no specific place allotted.
So pointers increase efficiency of a system

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.

Yes the pointer allows to use the memory more effectively. You use the memory as much as you require. You don't need to create extra redundant memory ahead of time like what we do in the case of array.
But yes playing with dynamic memory is also tricky. If you don't handle it properly you face
Memory leaks
Dangling pointer exceptions
If there are memory leaks in your program, then you may face the same memory issues as in case of array and it get be greater.
On the other hand if there is dangling pointer exceptions due to dynamic memory in your, your program will perform badly, it will label as crap and buggy.
So yes the dynamic memory is blessing, but it can be forbidding if not done properly.

he weightage  of GDb is 5 

So ur GDb should be limit in between 100 to 150 words ,,,,,

All the best 

when you use a pointer it directly points to a distinct memory address.it increases efficiency of system because when you use arrays, etc and other data types. they just allocate the memory randomly,i.e. there is no specific place allotted.
So pointers increase efficiency of a system.

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.

RSS

Looking For Something? Search Here

HELP SUPPORT

This is a member-supported website. Your contribution is greatly appreciated!

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

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

.