• Steven's avatar
    fix(server): prevent memory exhaustion in thumbnail generation · 8f29db2f
    Steven authored
    Address high memory usage when opening resource tab (fixes #5183) by implementing:
    
    1. Concurrency control: Limit thumbnail generation to 3 concurrent operations using semaphore to prevent memory exhaustion when many images are requested simultaneously
    
    2. S3 optimization: Skip server-side thumbnail generation for S3-stored images by default. S3 images now use presigned URLs directly, avoiding:
       - Downloading large images from S3 into server memory
       - Decoding and resizing images on the server
       - High memory consumption during batch requests
    
    3. Memory management improvements:
       - Explicitly clear blob and decoded image from memory after use
       - Restructure thumbnail cache check to avoid unnecessary semaphore acquisition
       - Double-check pattern to prevent duplicate generation while waiting
    
    This restores the original S3 behavior before commit e4f63453 while maintaining thumbnail support for local/database storage.
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
    8f29db2f
go.mod 4.23 KB