Skip to main content
Topic: Out of memory on manage attachments page (Read 3343 times) previous topic - next topic - Topic derived from A smarter way to handle direc...
0 Members and 1 Guest are viewing this topic.

Out of memory on manage attachments page

One of my sites has 150,000 plus attachments in 5 directories.  It runs OOM when trying to reach attachment settings or folders in the ACP.  Could that be addressed here?

Re: Out of memory on manage attachments page

Reply #1

@badmonkey that sounds odd, I'm not sure why it should have such a problem. :-\
Bugs creator.
Features destroyer.
Template killer.

Re: Out of memory on manage attachments page

Reply #2

If it's unusual not sure how to troubleshoot it?  Raising the php memory limit to 2G allows the interface to work.  If it is indeed unusual, does anyone else using elk have attachment directories as large?

Re: Out of memory on manage attachments page

Reply #3

Not this large, Badmonkey.  We have 66.790 attachments with 3.827.119 KB

Re: Out of memory on manage attachments page

Reply #4

I split the topic so the discussion is easier to follow.

On which page exactly goes out of memory? (Just to be sure.)
Bugs creator.
Features destroyer.
Template killer.

Re: Out of memory on manage attachments page

Reply #5

Quote from: emanuele – I split the topic so the discussion is easier to follow.

On which page exactly goes out of memory? (Just to be sure.)
 Thanks for addressing it eman.   ;)



ACP > Attachment Directories

and

ACP > Attachment Settings > Manage Attachment Directories

both result in 500 errors due to OOM.  I said 2G memory limit will cover it, and it will, but don't know the EXACT limit that will work.   :-X




Re: Out of memory on manage attachments page

Reply #6

Is that 1.0 or 1.1 (I'm not sure its any different but just want to be sure)

Re: Out of memory on manage attachments page

Reply #7

Could possibly be this code

Code: [Select]
	// Count the files with a glob, easier and less time consuming
$num_files = count(glob($dir . '/*.elk'));

EDIT: Tested with 180k files in one dir, down to 7MB memory from 40+MB. In ./sources/subs/ManageAttachments.subs.php, find the above code and replace with
Code: [Select]
	// Count the files with an iterator for a smaller memory footprint.
$num_files = count(new GlobIterator($dir . '/*.elk'));

EDIT2: This is 1.0.
LiveGallery - Simple gallery addon for ElkArte

Re: Out of memory on manage attachments page

Reply #8

The forum in question uses 1.1.   8)

Re: Out of memory on manage attachments page

Reply #9

https://github.com/elkarte/Elkarte/blob/c58a9e6ecf9ea836d77d02a2ff458b7413b755bf/sources/subs/ManageAttachments.subs.php#L1282

Code: [Select]
	$num_files = count(iterator_to_array($glob));

replace wth

Code: [Select]
	$num_files = $glob->count();
LiveGallery - Simple gallery addon for ElkArte

Re: Out of memory on manage attachments page

Reply #10

It looks like you can't backport that fix to 1.0.x because it requires PHP 5.3 or higher. :)

Re: Out of memory on manage attachments page

Reply #11

Thanks for the debug  :D ... I added this to the 1.1 tracker so we don't miss this in the final.

Re: Out of memory on manage attachments page

Reply #12

Thanks Spuds!
I wanted to do it this morning but I was already a bit late. O:-)
Bugs creator.
Features destroyer.
Template killer.