0

Memory allocation question ?

What happens when we try to allocate memory after already allocating before once like ; (1). int *ptr=malloc(12); ptr=malloc (18); Or (2). int *ptr=malloc(12); ptr=malloc (6);

5th Jan 2019, 5:56 PM
Sahil Bhakat
Sahil Bhakat - avatar
2 Réponses
+ 4
It's called a memory leak. The old data stay assigned to your program, yet they are unreachable and other programs won't be able to use that memory until your program terminates ( usually ). https://en.wikipedia.org/wiki/Memory_leak
5th Jan 2019, 6:19 PM
Dennis
Dennis - avatar
0
Thanks Dennis
6th Jan 2019, 6:48 AM
Sahil Bhakat
Sahil Bhakat - avatar