Writing Mobile Code Essential Software Engineering for Building Mobile Applications [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Writing Mobile Code Essential Software Engineering for Building Mobile Applications [Electronic resources] - نسخه متنی

Ivo Salmre

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید











Performance and Memory Management Summary


How you manage memory in your mobile application both at macro and micro levels will have an overwhelming effect on what you will be able to achieve in your mobile development efforts. In designing your mobile application's memory-usage model and writing your algorithms, it is important to be mindful of what you are driving the garbage collector to do in response to your decisions. Although you are not in explicit control of the garbage collector it has a strong influence on the overall performance of managed-code applications. Native code developers will have similar kinds of issues but will need to manage their memory themselves. Full garbage collections are expensive; the runtime needs to go through all the live top-level objects and trace down the tree of subobjects to find all the objects still in use so that the remaining garbage objects can be reclaimed. Each garbage collection has a fixed minimum cost based on the number of objects that need to be looked at; repeating the operation often will cause a significant drag on your application.

How often the garbage collector runs is directly determined by how quickly your code creates memory pressure in your application. Two things combine to create memory pressure in applications: (1) the total amount of application state you maintain, which means any forms, global objects, user data, and any objects contained inside global parent objects; and (2) the temporary objects you create and destroy through the running of your algorithms. The memory-usage pattern of your application will resemble a saw-tooth wave. The height of the saw tooth is determined by how much working space you leave for your algorithms to usethat is, the space not taken up by your steady-state allocated memory. The upward slope of the saw tooth is determined by how efficient your algorithms are with their object allocations. The more frugal your algorithms are in new object allocation, the more gradual the slope of the saw tooth. Eventually the memory usage will cross a threshold and garbage collection will be triggered to clean up all unused objects.

Figures 12.1, 12.2, 12.3, and 12.4 describe four basic patterns of memory usage.

Figure 12.1. The worst case: excessive application state and wasteful algorithms.

[View full size image]

Figure 12.2. An intermediate case: efficient application state but wasteful algorithms.

Figure 12.3. An intermediate case: excessive application state but economical algorithms.

Figure 12.4. The best case: efficient application state and economical algorithms.


/ 159