2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
캐시된 앱 고정기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Android 11 QPR3 이상은 캐시된 앱 고정기를 지원합니다. 이 기능은 캐시된 프로세스의 실행을 중지하고 캐시된 상태에서 작업을 시도할 수 있는 오작동하는 앱에 의한 리소스 사용량을 줄입니다. 프레임워크는 프로세스를 고정된 cgroup으로 마이그레이션하여 캐시된 앱을 고정합니다. 이렇게 하면 캐시된 활성 앱이 있을 때 활성 및 유휴 CPU 사용량이 줄어듭니다.
앱 고정기는 시스템 구성 플래그나 개발자 옵션으로 사용 설정할 수 있습니다.
앱 고정기 구현
캐시된 앱 고정기는 커널 cgroup v2 고정기를 사용합니다. 호환되는 커널과 함께 제공되는 기기는 선택적으로 캐시된 앱 고정기를 사용 설정할 수 있습니다. 이렇게 하려면 개발자 옵션 '캐시된 앱 실행 정지'를 사용 설정하거나 기기 설정 플래그 activity_manager_native_boot use_freezer
를 true
로 설정합니다. 예:
adb shell device_config put activity_manager_native_boot use_freezer true && adb reboot
플래그 use_freezer
가 false로 설정되거나 개발자 옵션이 사용 중지되면 고정기가 사용 중지됩니다. 소프트웨어 출시 또는 업데이트에서 기기 설정을 변경하여 이 설정을 전환할 수 있습니다.
앱 고정기는 공식 API를 노출하지 않고 참조 구현 클라이언트가 없으나 숨겨진 시스템 API setProcessFrozen
및 enableFreezer
를 사용합니다. 이러한 API에 관한 자세한 내용은 ActivityManager의 Process.java
및 ActivityManagerService API를 참고하세요. 개발자는 ActivityManager
의 클라이언트 코드에서 실험을 참고할 수도 있습니다.
맞춤 기능 처리
일반적으로 캐시된 프로세스는 어떠한 작업도 하지 않을 것으로 예상되지만, 일부 앱에는 캐시된 동안 실행될 것으로 예상되는 프로세스가 지원하는 맞춤 기능이 있을 수 있습니다. 이러한 앱을 실행하는 기기에서 앱 고정기가 사용 설정되면 캐시된 프로세스가 멈추고 맞춤 기능이 작동하지 않을 수 있습니다.
앱에 캐시된 동안 활동을 실행해야 하는 프로세스가 있는 경우 앱이 활성 상태로 유지되도록 프로세스가 작업을 처리해야 하기 전에 프로세스 상태를 캐시되지 않음(예: Bound ForeGround Service(BFGS) 또는 포그라운드)으로 변경하는 방법을 사용할 수 있습니다.
앱 고정기 테스트
앱 고정기가 의도대로 작동하는지 확인하려면 다음 리소스를 사용하세요.
adb shell dumpsys activity
명령어를 사용하여 고정된 프로세스 목록을 확인하고 grep 명령어를 사용하여 Apps frozen:
를 검색합니다.
/sys/fs/cgroup/uid_0/cgroup.freeze
파일이 있는지 확인합니다.
프로세스가 고정기 내부 또는 외부로 이전될 때마다 고정 및 고정 해제된 항목을 보여주는 logcat을 확인합니다. 예:
adb logcat | grep -i "\(freezing\|froze\)"
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Cached apps freezer\n\nAndroid 11 QPR3 or higher supports the cached apps\nfreezer. This feature stops execution for cached processes and reduces resource\nusage by misbehaving apps that might attempt to operate while cached. The\nframework freezes cached apps by migrating their processes into a frozen cgroup;\nthis reduces active and idle CPU consumption in presence of active cached apps.\nThe app freezer can be enabled using a system configuration flag or a developer\noption.\n\nImplement the apps freezer\n--------------------------\n\nThe cached apps freezer leverages the kernel cgroup v2 freezer. Devices shipping\nwith a compatible kernel can (optionally) enable it. To do so, enable the\ndeveloper option \"Suspend execution for cached apps\" or set the device config\nflag `activity_manager_native_boot use_freezer` to `true`. For example: \n\n adb shell device_config put activity_manager_native_boot use_freezer true && adb reboot\n\nThe freezer is disabled when the flag `use_freezer` is set to false or the\ndeveloper option is disabled. You can toggle this setting by changing a device\nconfiguration in a software release or update.\n\nThe apps freezer doesn't expose official APIs (and doesn't have a reference\nimplementation client), but does use the hidden system APIs `setProcessFrozen`\nand `enableFreezer`. For details on these APIs, refer to ActivityManager's\n`Process.java` and the ActivityManagerService API. Developers can also refer to\nthe client code in `ActivityManager` for experiments.\n\nHandle custom features\n----------------------\n\nTypically, processes aren't expected to do any work when cached, but some apps\nmight have custom features supported by processes that are expected to run while\ncached. When the apps freezer is enabled on a device running such an app, the\ncached processes are frozen and might prevent custom features from working.\n\nAs a workaround, if an app has a process that needs to perform activities while\ncached, change the process status to non-cached (such as Bound ForeGround\nService (BFGS) or foreground) before the process needs to do any work to allow\nthe app to remain active.\n\nTest the apps freezer\n---------------------\n\nTo verify the app freezer is working as intended, use the following resources:\n\n- Check for a list of frozen processes using the `adb shell dumpsys activity`\n command and grep for `Apps frozen:`.\n\n- Check for the presence of the `/sys/fs/cgroup/uid_0/cgroup.freeze` file.\n\n- View logcat, which shows frozen and unfrozen entries each time a process\n migrates in or out of the freezer. For example:\n\n adb logcat | grep -i \"\\(freezing\\|froze\\)\""]]