SHARE
TWEET

Untitled

a guest Feb 21st, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Operates with Q memory
  2. void FantasyMethod() {
  3.     var o = new BigObject();
  4.  
  5.     {
  6.         var temp = new BigObject();
  7.         Populate(temp); // Populates o1 with N megabytes of data
  8.  
  9.         o = PerformSomeOperationsOn(temp); // Returns a BigObject of size M (M is close to N)
  10.  
  11.         // Currently, M+N memory is occupied, we have Q-M-N free
  12.     }
  13.  
  14.     // Let's tell the garbage collector to catch up
  15.     GC.Collect();
  16.     GC.WaitForPendingFinalizers();
  17.  
  18.     // Currently, M memory is occupied
  19.  
  20.     DoUsefulStuffWith(o); // This method can only work if at least Q-M-N/2 memory is free
  21. }
  22.    
  23. using (var b = new DisposableObject())
  24. {
  25.    ...
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top