Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement