Ajax in Action phần 6

Trong cả hai trường hợp, nhiều tính chất phong cách viết bằng một ký hiệu cặp khoá-giá trị, cách nhau bằng dấu chấm phẩy. CSS có thể xác định cách bố trí | Designing for performance 311 this MyObject is a user-defined type. Every instance will refer to a DOM node as and the DOM node will refer back to the JavaScript object as . To remove this circular reference while finalizing the object we might offer a method such as this function null null By setting both references to null we break the circular reference. Alternatively a DOM tree could be cleaned up in a generic fashion by walking the DOM tree and eliminating references on the basis of name type or whatever. Richard Cornford has suggested such a function specifically for dealing with event handler functions attached to DOM elements see the Resources section at the end of this chapter . My feeling is that generic approaches such as this should be used only as a last resort as they may scale poorly to the large document trees typified by Ajax rich clients. A structured pattern-based approach to the codebase should enable the programmer to keep track of the specific cases where cleanup is required. A second point worth noting for IE is that a top-level undocumented function called CollectGarbage is available. Under IE v6 this function exists and can be called but seems to be an empty stub. We have never seen it make a difference to reported memory in the Task Manager. Now that we understand the issues of memory management let s explore the practicalities of measuring it and applying those measurements to a real-life application. Designing for performance We stated at the outset that performance consisted of both good execution speed and a controllable memory footprint. We also said that design patterns could help us to achieve these goals. In this section we ll see how to measure memory footprint in real applications and we ll use a simple example to show how the use of design patterns can help us to understand the fluctuations in memory footprint that we

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
245    1    1    18-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.