HI , Is Delete Operator release Memory immediately . I mean if i am using delete at some point in my program does my process immediately release the Memory and does OS will be able to use it for other process or their is some other mechanism for OS get released memory back where can i get knowledge about this . please give me the direction , reference's ,books name . does it depends on compiler Or Operating System ?? Regards Rahul
I think you are not understanding the concept of release. Any memory not associated by any valid pointer is actually released. I will explain in a better example. Let us say you have a drive filled with all images. Your memory card. Now you delete the files using your OS. Do you think it is same as format of card. No. Card files actually reside on the card but it is just that the pointer to those files are wiped. You can actually recover the files by reading sectors of the disk. With the same analogy there is not need to clean the memory unless it is needed once again and so OS does the process to work for better user experience.
Sir actually i asked this question in the context that when i am deleting object even my process dose not showing decrement in Memory Usage as i seen this in task manager so dose my process keeping this memory until OS doesn't require that memory for some another process OR OS take it back from the process Regards Rahul
Task manager unit may in MG (if not GB) and you are allocating bytes and releasing it. Even if it shows then you cannot see it with naked eyes.
Sir I am getting memory detail from memory used by process that we can get from PROCESS Tab i think we get memory in KB's and i am writing a memory intensive code for that Code: _tmain() { int i=0; long int j=0,k; char c; CArray<CString,CString> mycarray; cout<< "\nbefore creating object"; [COLOR="Blue"]LABLE1[/COLOR] for(k=1;k<5;k++) { for(j=1;j<25000 ;j++) { mycarray.Add( _T("this is test")); mycarray.Add( _T("this is test")); mycarray.Add( _T("this is test")); mycarray.Add( _T("this is test")); mycarray.Add( _T("this is test")); } cout<<"\nadded 10,000 elements "; mycarray.RemoveAll(); [COLOR="Blue"] LABLE2[/COLOR] cout<<"\nremoved\n"; } }// end of main i want to when i run this program there is a big diffrence in memory used by process which i can see in process tab of task manager the two places are lable 1 and lable2 in ideal way memory used by process at labe1 -lable2 ~=0 i.e before adding elements to the CArray and after Removing elements from the CArray memory usage by process must be same isnt it ? but this is not happening