I am come to optimize my flash application.
Just a quick question what’s the different to null and dispose?
and what situation to use which?
Thanks very much for any suggestion.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Setting to null is safer, as it allows GC to collect an object only after it becomes unreferenced from anywhere. If you, for example, dispose() a BitmapData which is still referenced, you will receive an exception. If you are absolutely sure that a certain object is not referenced from anywhere, for example, if the BitmapData in question is temporary, and there is only one reference to it, you can use dispose() to free memory. The best solution in case of rapid allocation/deallocation of temporary objects will be reserving memory for them and actually reusing them when you need to.