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

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

+ 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: 1868

.

+ 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

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.

int and char are data types. They are a known size, so the compiler can lay out memory at compile time. When you request memory dynamically, say for 100 chars, the compiler can translate that into a request for 100 bytes. Not impressive for chars, but ints, short ints and long ints vary in size obviously by definition, but also by hardware architecture ( 16, 32 or 64 bit ).

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.

In my opinion I will support the given statement "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"  because of following reasons:

Pointers are used to store and manage the addresses of dynamically allocated blocks of memory. Such blocks are used to store data objects or arrays of objects. Most structured and object-oriented languages provide an area of memory, called the heap or free store, from which objects are dynamically allocated.

Another interesting aspect of pointer is the NULL value. Whenever we define a pointer
or declare a pointer, normally, it is initialized to a NULL value. NULL has been defined
in the header files stdlib.h and stddef.h. So at least one of these files must be included in
the program’s header to use the NULL. A NULL pointer is a special type of pointer with
all zeros value. All zeros is an invalid memory address. We can’t use it to store data or to
read data from it. It is a good way to ascertain whether a pointer is pointing to a valid
address or has a NULL value.

These characteristics of pointer are definitely showing that the computer memory is efficiently utilized by initially giving a null value to the pointer but can be problematic if the syntax is not correct for example. Using only ptr instead of *ptr will rise a compile error.

Yes..Because pointers are the variables containg memory address of other variable ,(In a C program)
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. :-)

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 beats in both task the design time memory allocation.



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.

Dynamic memory allocation

The task of fulfilling an allocation request consists of locating a block of unused memory of sufficient size. Memory requests are satisfied by allocating portions from a large pool of memory called the heap. At any given time, some parts of the heap are in use, while some are "free" (unused) and thus available for future allocations. Several issues complicate implementation, such as internal and external fragmentation, which arises when there are many small gaps between allocated memory blocks, which invalidates their use for an allocation request. The allocator's metadata can also inflate the size of (individually) small allocations. This is managed often by chunking. The memory management system must track outstanding allocations to ensure that they do not overlap and that no memory is ever "lost" as a memory leak.

The task of fulfilling an allocation request consists of locating a block of unused memory of sufficient size. Memory requests are satisfied by allocating portions from a large pool of memory called the heap. At any given time, some parts of the heap are in use, while some are "free" (unused) and thus available for future allocations. Several issues complicate implementation, such as internal and external fragmentation, which arises when there are many small gaps between allocated memory blocks, which invalidates their use for an allocation request. The allocator's metadata can also inflate the size of (individually) small allocations. This is managed often by chunking. The memory management system must track outstanding allocations to ensure that they do not overlap and that no memory is ever "lost" as a memory leak.

A.A.

A short solution.........

I got 3.75

I got 3.75

RSS

Latest Activity

彡JK彡 ❤️ replied to + Iuuoɔǝut +'s discussion یہ محبت ہی میری خطا ہوگئی
50 minutes ago
彡JK彡 ❤️ replied to + ! ! ! ! ! MySterIouS's discussion ~ Khoobsorat Ahsaas ~
55 minutes ago
彡JK彡 ❤️ liked + ! ! ! ! ! MySterIouS's discussion ~ Khoobsorat Ahsaas ~
59 minutes ago
彡JK彡 ❤️ replied to Mani Siddiqui BS VIII's discussion Kash Main Doure Payamber
1 hour ago
彡JK彡 ❤️ replied to +¢αяєℓєѕѕ gιяℓ's discussion Khuda Aur Insan
1 hour ago
彡JK彡 ❤️ replied to Mariam Faridoon's discussion Assignment Solution Required EDU 402
1 hour ago
彡JK彡 ❤️ replied to Mariam Faridoon's discussion Assignment Solution Required EDU 402
1 hour ago
彡JK彡 ❤️ replied to +"Alan Walker"++'s discussion Meri Diary.................
1 hour ago
彡JK彡 ❤️ liked +"Alan Walker"++'s discussion Meri Diary.................
1 hour ago
彡JK彡 ❤️ replied to Annu's discussion Please share solution for assig # 01 of wdu 602 fall 2019
1 hour ago
彡JK彡 ❤️ liked Annu's discussion Please share solution for assig # 01 of wdu 602 fall 2019
1 hour ago
彡JK彡 ❤️ replied to stylo's discussion entazar
1 hour ago
彡JK彡 ❤️ liked Muhammad Tariq Mahmood's discussion cs507 assignment a 2019
1 hour ago
彡JK彡 ❤️ liked najeeb ullah's discussion Cs 502 Asssignment no 1 solution
1 hour ago
彡JK彡 ❤️ liked hussnain's discussion CS601 - Data Communication
1 hour ago
彡JK彡 ❤️ liked Aini MCS's discussion CS301 assignment solution required
1 hour ago
彡JK彡 ❤️ replied to Sheraz Ali's discussion Need MTH 601 - Operations Research Assignment # 1 ....Nov 18, 2019
1 hour ago
彡JK彡 ❤️ liked Sheraz Ali's discussion Need MTH 601 - Operations Research Assignment # 1 ....Nov 18, 2019
1 hour ago
Sheraz Ali posted a discussion
3 hours ago
Imran Khan replied to +¢αяєℓєѕѕ gιяℓ's discussion CS506 - Web Design and Development Assignment No.1 Due Date Nov 15, 2019 in the group CS506 Web Design and Development
4 hours ago

Today Top Members 

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

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