+ 1

what is garbage value?

is it have any importance for this

29th Jul 2016, 6:53 PM
kavya
kavya - avatar
5 Answers
+ 3
Memory management is one of the most crucial works for any programming language. Considering an application that reads a set of data and than write it to a database, for this it will use some intermediary storage place where it will store the data before putting it on to the database. Now, if that intermediary memory place is not cleared of the previous data it might result into its exhaustion which will bring our application down. To prevent such a case from occurring there can be two ways, one, clear the memory manually like in C++ or C, else, employ a background process of garbage collection to do this work automatically.
29th Jul 2016, 7:03 PM
naman
naman - avatar
+ 1
In a language like C, when you define a variable, like: int x; a small block of memory is allocated to the variable. However, we have only declared the variable, and not initialized it, which means that the block of memory that has been allocated to the variable still contains some value that has been left over from previous programs and operations. That value is called a garbage value. This may lead to erroneous results in programs. To avoid this, declare and initialize variables like this: int x =0;
29th Jul 2016, 7:05 PM
naman
naman - avatar
0
it will automatically deallocate the memory
30th Jul 2016, 1:33 AM
Ravi Teja
Ravi Teja - avatar
0
I can't understand that how garbage value automatically holds
30th Jul 2016, 11:26 AM
kavya
kavya - avatar
0
😁
30th Jul 2016, 12:59 PM
Yajiv
Yajiv - avatar