Block memory problem

fmahannah

Joined: 2002-12-08
Posts: 10
Posted: Wed, 2004-06-02 12:51

Using the random block in post nuke and it is running out of memory with only a couple hundred photos (8 meg php memory limit). The largest album has only 190 photos. I can't believe that it uses 8 megs of memory to read a couple text files and decide which photo to display.

Tracing in the code shows that the memory runs out when rebuilding the cache. Checking the code for rebuilding the cache shows that the scan albums function loads all the albums and apparently loads the photos from the dat files, this is where the memory runs out .... when it tries to unserialize the 199K dat file for the largest album with 190 photos.

It should be able to load this dat file into an array with no problems, I have loaded much larger arrays from DB queries so there is something wrong with the code that rebuilds the cache.

Inside the gallery the large album displays just fine, and it uses the same code to load the album data that the cache rebuilding function uses, so why does it work in the gallery and run out of memory for the block?

To me it would seem that we could grab the album list, pick one at random, get the cached photo count for the album we picked, pick a random number within that range, and build the URL to display the selected photo .... all without fully loading every album and every photo in the albums.

I am not much of a coder (more of a hacker) but I am going to try to figure out how to do this myself if nobody else has done anything along these lines. I can see a memory problem with thousands of photos but not a couple hundred.

Please if anyone has written a more memory friendly random block let me know where I might grab it.

Thanks. I love gallery but the limitations of it not using MySQL tables instead of text files keep running me into brick walls. Hopefully there will be a way to import old galleries into the new one if it is DB based. :lol:

 
Warren
Warren's picture

Joined: 2002-07-24
Posts: 794
Posted: Wed, 2004-06-02 14:45

Using Gallery embedded in nuke is a huge memory hog! The alocation is not just the function usage but also includes the whole page. Your milage may vary as the saying goes. I have gone up to 50MB now! Deponding on what version of Apache you may be using... you also need to adjust memory usage elsewhere if using version 2. Check for /etc/httpd/conf.d/php.conf in my example of 50MB I use this line: LimitRequestBody 50000000.