Fix GH-9812: memory leak on repeated include with file_cache_only=1#22107
Open
pronskiy wants to merge 1 commit into
Open
Fix GH-9812: memory leak on repeated include with file_cache_only=1#22107pronskiy wants to merge 1 commit into
pronskiy wants to merge 1 commit into
Conversation
With opcache.file_cache_only=1 every include allocates a fresh arena in zend_file_cache_script_load() and it leaks. Looks like zend_arena_release() only runs when cache_it is set, which is the SHM path. CG(arena) only resets at request shutdown, so I think memory just keeps growing. My attempt: per-request hashtable in ZCG, resolved path -> zend_persistent_script. First include fills it, next ones should reuse the arena allocation. Freeing it in accel_post_deactivate seems to work since it runs before zend_arena_destroy and shutdown_memory_manager, so entries and buckets should still be alive. Fixed phpGH-9812 Closes phpGH-9812
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
opcache.file_cache_only=1every include allocates a fresh arena inzend_file_cache_script_load()and it leaks. Looks likezend_arena_release()only runs whencache_itis set, which is the SHM path. CG(arena) only resets at request shutdown, so I think memory just keeps growing.My attempt: per-request hashtable in ZCG mapping resolved path -> zend_persistent_script. First include fills it, next ones should reuse the arena allocation. Freeing it in
accel_post_deactivateseems to work since it runs beforezend_arena_destroyandshutdown_memory_manager, so entries and buckets should still be alive.Fixed GH-9812
Closes GH-9812