code_junkie

Ruby Memory Management

Nov 11th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. def method(x)
  2. x.split( doesn't matter what the args are )
  3. end
  4.  
  5. def method(x)
  6. x.gsub( doesn't matter what the args are )
  7. end
  8.  
  9. students.each do |student|
  10. cloned_student = student.clone
  11. ...
  12. cloned_student.books.detect {...}
  13. ca_teachers = cloned_student.teachers.detect {|teacher| teacher.address.state == 'CA'}
  14. ca_teachers.blah_blah
  15. ...
  16. # Not sure if the following is necessary, but we have it just in case...
  17. cloned_student = nil
  18. end
  19.  
  20. students.each do |student|
  21. loop_student = Student.find(student.id) # just re-find the record into local variable.
  22. ...
  23. loop_student.books.detect {...}
  24. ca_teachers = loop_student.teachers.detect {|teacher| teacher.address.state == 'CA'}
  25. ca_teachers.blah_blah
  26. ...
  27. end
Add Comment
Please, Sign In to add comment