LycheeOrg / Lychee

A great looking and easy-to-use photo-management-system you can run on your server, to manage and share photos.
https://lycheeorg.github.io/
MIT License
3.37k stars 298 forks source link

Loading large album fails on memory error #1178

Closed vjuliano closed 2 years ago

vjuliano commented 2 years ago

Detailed description of the problem [REQUIRED]

I made my recent album contain all photos from last 300 days. Its alot of photos. Album::get fails on { "message": "Allowed memory size of 134217728 bytes exhausted (tried to allocate 10395648 bytes)", "exception": "Symfony\Component\ErrorHandler\Error\FatalError", "file": "/mnt/server/Lychee/vendor/symfony/http-foundation/Response.php", "line": 381, "trace": [] }

I have attached the entire request/response as a text file

I suspect I have a php memory constraint set somewhere, but it looks like ive upped all of them to 500MB. The error is for 128MB, which I think is still higher than any php default would be.

Steps to reproduce the issue

Steps to reproduce the behavior:

  1. In settings, set the Smart Album recent age far enough back to load too many images.
  2. Go back to main gallery and load Recents

Output of the diagnostics [REQUIRED]

Diagnostics
-------
Warning: Dropbox import not working. dropbox_key is empty.

System Information
--------------
Lychee Version (git):            master (a7de020) - Data not in Cache
DB Version:                      4.4.0

composer install:                dev
APP_ENV:                         production
APP_DEBUG:                       true

System:                          Linux
PHP Version:                     8.1
PHP User agent:                  Lychee/4 (https://lycheeorg.github.io/)
Max uploaded file size:          500M
Max post size:                   500M
Max execution time:              200
MySQL Version:                   10.5.13-MariaDB-0ubuntu0.21.10.1

Imagick:                         1
Imagick Active:                  1
Imagick Version:                 1691
GD Version:                      2.3.0

Config Information
--------------
version:                         040400
check_for_updates:               1
sorting_Photos_col:              id
sorting_Photos_order:            DESC
sorting_Albums_col:              max_taken_at
sorting_Albums_order:            DESC
imagick:                         1
skip_duplicates:                 1
small_max_width:                 0
small_max_height:                360
medium_max_width:                1920
medium_max_height:               1080
lang:                            en
layout:                          1
image_overlay_type:              none
default_license:                 CC-BY-NC-ND-4.0
compression_quality:             90
full_photo:                      1
delete_imported:                 1
Mod_Frame:                       1
Mod_Frame_refresh:               30
thumb_2x:                        1
small_2x:                        1
medium_2x:                       1
landing_page_enable:             1
landing_owner:                   Vincent Juliano
landing_title:                   Life on 35mm
landing_subtitle:                Click top right to continue.  Next page top left to login
landing_facebook:                
landing_flickr:                  
landing_twitter:                 
landing_instagram:               
landing_youtube:                 
landing_background:              /uploads/medium/3d4bf4e35e5ea06853d7983c88efb6a2.jpg
site_title:                      Vince Juliano's Photo Gallery
site_copyright_enable:           1
site_copyright_begin:            2021
site_copyright_end:              2021
additional_footer_text:          "Alex's Photos" copyright Alex Panicacci 2021
display_social_in_gallery:       0
public_search:                   0
SL_enable:                       0
SL_for_admin:                    0
public_recent:                   0
recent_age:                      300
public_starred:                  0
downloadable:                    1
photos_wraparound:               1
map_display:                     1
zip64:                           1
map_display_public:              1
map_provider:                    Wikimedia
force_32bit_ids:                 0
map_include_subalbums:           1
update_check_every_days:         3
has_exiftool:                    1
share_button_visible:            0
import_via_symlink:              0
has_ffmpeg:                      1
location_decoding:               1
location_decoding_timeout:       30
location_show:                   1
location_show_public:            1
rss_enable:                      0
rss_recent_days:                 7
rss_max_items:                   100
prefer_available_xmp_metadata:   0
editor_enabled:                  1
lossless_optimization:           1
swipe_tolerance_x:               150
swipe_tolerance_y:               250
local_takestamp_video_formats:   .avi|.mov
log_max_num_line:                1000
unlock_password_photos_with_url_param: 0
nsfw_visible:                    0
nsfw_blur:                       0
nsfw_warning:                    0
nsfw_warning_admin:              0
map_display_direction:           1
album_subtitle_type:             oldstyle
upload_processing_limit:         4
public_photos_hidden:            1
new_photos_notification:         1

Browser and system

Mac Os 11.6.1 Firefox 95.0.2

albumGetResponse.txt

vjuliano commented 2 years ago

I was able to coax it into loading, by returning via one of the settings pages, but then it locked up the browser for about 15 min before I killed it.

kamil4 commented 2 years ago

You may want to check issue #1193 for some discussion on this...

kamil4 commented 2 years ago

BTW, the memory limit you are hitting is memory_limit. If you are using Apache with mod_php, you can simply add the following line to Lychee/public/.htaccess right next to the other php limits:

        php_value memory_limit 500M
joshuacwnewton commented 5 months ago

I ran into the same issue, and editing .htaccess did not help me.

I am using the linuxserver.io docker image + docker compose. Instead, I went to the config dir and edited user.ini.

user@hostname:/# ls /config
custom.js  keys  log  nginx  php  sym  user.css  user.ini  www

This file has similar contents, so I added the same line, and this time I noticed a difference:

  ; Uncomment these lines to change PHP parameters if you are using PHP with CGI or FastCGI. Only works with PHP starting from 5.3.0.
  ; Note that with FastCGI, you might also want to set FcgidBusyTimeout, FcgidIOTimeout and FcgidMaxRequestLen in your Apache config

  max_execution_time = 200
  post_max_size = 200M
  upload_max_size = 200M
  upload_max_filesize = 20M
  max_file_uploads = 200
+ memory_limit = 500M

[!NOTE] The default seems to be 134217728 bytes (128MiB). So, to test which configurations actually took effect, I first changed the value 129M to observe a change in the error message. Only user.ini caused the error message to update to "Allowed memory size of 135266304 bytes exhausted". Then I switched it to a sufficient amount (500M).