[wp-trac] [WordPress Trac] #24688: Memory exhaustion caused by very many unattached media

WordPress Trac noreply at wordpress.org
Mon Jun 2 23:16:37 UTC 2025


#24688: Memory exhaustion caused by very many unattached media
-------------------------------------------------+-------------------------
 Reporter:  andy                                 |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Media                                |     Version:  2.5
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-test-info reporter-    |     Focuses:
  feedback                                       |  performance
-------------------------------------------------+-------------------------
Changes (by SirLouen):

 * keywords:  has-patch needs-testing => has-patch has-test-info reporter-
     feedback
 * focuses:   => performance


Comment:

 == Reproduction Report
 === Description
 ❌ This report can't validate that the issue can be reproduced.

 === Environment
 - WordPress: 6.9-alpha-60093-src
 - PHP: 8.2.28
 - Server: nginx/1.27.5
 - Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
 - Browser: Chrome 137.0.0.0
 - OS: Windows 10/11
 - Theme: Twenty Fourteen 4.2
 - MU Plugins: None activated
 - Plugins:
   * Bulk Image Generator 1.0.0
   * Image Memory Exhaustion Tester 1.0.0
   * Test Reports 1.2.0

 === Test Reproduction Suite

 1. First, I have created 2000 images for the test. It is easy to
 extrapolate results to 30K but the time it takes to do the whole process
 is unnecessary in the memory consumption doesn't scale.
 - For this purpose I'm using my plugin for generating placeholder images
 of different sizes: https://raw.githubusercontent.com/SirLouen/bulk-image-
 generator/refs/tags/1.0.0/bulk-image-generator.php
 2. Secondly I'm generating a total of 2000 images for the test as I said
 with the previous plugin
 3. Finally, I had to create an ad-hoc code to test this specific scenario:
 https://raw.githubusercontent.com/SirLouen/image-memory-exhaustion-
 tester/refs/tags/1.0.0/image-memory-exhaustion-tester.php
 4. It's very important to increase in the PHP server, the
 `max_execution_time`, put a good number, like 3000 seconds or something
 like that. Depending on your computer running through 2000 images can take
 a while
 5. Run the memory tester plugin
 6. ❌ No special memory exhaustion problems allocated (attached logs in
 Supplemental Artifacts section)

 === Actual Results
 1.  ❌ Error condition is not occurring

 === Additional Notes
 - Please review steps taken to verify if I'm not taking something into
 consideration, or if any of my plugins (specially the memory testing
 part), is doing what is being reported. Occasionally, it's very difficult
 to reproduce the same scenario in the same way that the reporter is
 running it. This is why I've been recommending for quite a while now that
 reporters, specially when they report any specific performance issues, to
 provide code samples or whatever Testing Use-Case they think could be
 valid
 - @davidbinda @iCaleb, how were you able to test your patches?
 - Given that this report is so old, maybe it was solved at some point in
 between.

 PS: Generally I don't spend so much time creating so much code to prove
 something. But I found that this was a great example report I want to also
 add to my Testing Use-Case article in the performance section.

 === Supplemental Artifacts
 - Bulk Image Generator plugin repo: https://github.com/SirLouen/bulk-
 image-generator/
 - Image Memory Exhaustion Tester plugin repo: https://github.com/SirLouen
 /image-memory-exhaustion-tester/

 {{{
 === Memory Exhaustion Test Results ===
 Start Time: 2025-06-02 20:24:39
 Initial Memory Usage: 36 MB
 Initial Peak Memory: 36 MB
 --- TEST 1: get_children() Function ---
 Attachments Found: 2010
 Execution Time: 0.1073 seconds
 Memory Increase: 14 MB
 Peak Memory Increase: 14 MB

 --- TEST 2: previous_image_link() Chain (Simulating Unattached Attachment
 Page) ---
 Found 2010 unattached images to test
 Progress: 100 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 200 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 300 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 400 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 500 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 600 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 700 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 800 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 900 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1000 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1100 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1200 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1300 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1400 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1500 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1600 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1700 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1800 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1900 images processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 2000 images processed, Current Memory: 52 MB, Peak: 52 MB
 Previous Image Link Calls: 2010
 Unattached Images Tested: 2010
 Execution Time: 66.2879 seconds
 Memory Increase: 2 MB
 Peak Memory Increase: 2 MB

 --- TEST 3: Direct adjacent_image_link() with post_parent=0 Simulation ---
 Progress: 50 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 100 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 150 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 200 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 250 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 300 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 350 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 400 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 450 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 500 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 550 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 600 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 650 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 700 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 750 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 800 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 850 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 900 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 950 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1000 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1050 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1100 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1150 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1200 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1250 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1300 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1350 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1400 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1450 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1500 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1550 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1600 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1650 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1700 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1750 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1800 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1850 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1900 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 1950 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Progress: 2000 attachments processed, Current Memory: 52 MB, Peak: 52 MB
 Adjacent Image Link Calls: 4020
 Attachments Tested: 2010
 Execution Time: 133.7525 seconds
 Memory Increase: 0 B
 Peak Memory Increase: 0 B

 --- OVERALL RESULTS ---
 Total Execution Time: 200.1479 seconds
 Final Memory Usage: 52 MB
 Final Peak Memory: 52 MB
 Total Memory Increase: 16 MB
 Total Peak Memory Increase: 16 MB

 PHP Memory Limit: 256M
 Memory Usage: 20.31% of limit
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/24688#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list