C/C++ programs inadvertently free/delete objects which are still in use:
int *p, *q; int *p, *q; p = malloc(sizeof(int)); p = new int; *p = 27; *p = 27; q = p; q = p; free(p); delete p; printf("%d\n", *q); cout << *q << endl;And programs often cause memory leaks by not using free/delete on unwanted objects.
Like Java, in C# you do not delete objects: instead, these languages have garbage collection. The garbage collector detects objects no longer in use, and reuses their space.