LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > PHP > emalloc / erealloc again with APC

Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2006, 08:43 AM
philwo philwo is offline
Member
 
Join Date: Aug 2006
Posts: 14
Default emalloc / erealloc again with APC

Hi,

I'm getting emalloc / erealloc errors in stderr.log which cause one of my vhosts not to work (I always get a 503 error). The single vhost which isn't working is serving a MediaWiki installation. The other (working) vhosts serve simple php-sites.

1) Ubuntu Dapper 6.06.1 64bit,
Linux peach 2.6.17.8 #4 Fri Aug 11 21:13:01 CEST 2006 x86_64 GNU/Linux

2) LiteSpeed 2.1.19 Standard

3) PHP 5.1.4 with LSAPI and APC 3.0.10

4) The wiki worked after I installed the LiteSpeed server (it's maybe 8 hours ago) and when I just looked, I got the 503 error. The only error-message I get is in stderr.log and says:

FATAL: erealloc(): Unable to allocate 30720 bytes
FATAL: erealloc(): Unable to allocate 30720 bytes
FATAL: emalloc(): Unable to allocate 7680 bytes
FATAL: emalloc(): Unable to allocate 7680 bytes
[...][Wed Aug 16 17:20:51 2006] [apc-error] apc_mmap: mmap failed: Cannot allocate memory
[Wed Aug 16 17:20:51 2006] [apc-error] apc_mmap: mmap failed: Cannot allocate memory
[Wed Aug 16 17:20:52 2006] [apc-error] apc_mmap: mmap failed: Cannot allocate memory
[...]
FATAL: emalloc(): Unable to allocate 7680 bytes
FATAL: emalloc(): Unable to allocate 7680 bytes
FATAL: erealloc(): Unable to allocate 30720 bytes
FATAL: erealloc(): Unable to allocate 30720 bytes

My setup is:
Server->Tuning:
Max Cached Small File Size (bytes) 4096
Total Small File Cache Size (bytes) 20M
Max MMAP File Size (bytes) 1M
Total MMAP Cache Size (bytes) 128M

Max Request Header Size (bytes) 8192
Max Request Body Size (bytes) 1G
Max Dynamic Response Header Size (bytes) 8K
Max Dynamic Response Body Size (bytes) 1G

VHost Template -> External App Definition (excerpt):
Name: $VH_NAME-php
Address: uds://tmp/lshttpd/$VH_NAME-php.sock
Max Connections: 20
Environment: PHP_LSAPI_MAX_REQUESTS=500
Instances: 20
Memory Soft Limit (bytes) 0
Memory Hard Limit (bytes) 0
Process Soft Limit 0
Process Hard Limit 0

I tried setting these limits to a very high number (memory about 160MB) instead of 0, but this didn't change anything. I restarted the server several times. If you need any more information, just tell me.

Regards,
Philipp
Reply With Quote
  #2  
Old 08-16-2006, 09:27 AM
xing xing is offline
LiteSpeed Staff
 
Join Date: Oct 2003
Location: Los Angeles, California
Posts: 380
Philipp,

Please try with "Server > Security > CGi Resources" memory soft/hard settings set also to "0" and/or a very high value.

Should not make a difference we want to test all scenarios to see if this is an internal config problem or an external problem.

Also make sure in php.ini that you have disabled max-memory limit option if that feature is compiled in.

Last edited by xing; 08-16-2006 at 09:30 AM..
Reply With Quote
  #3  
Old 08-16-2006, 09:33 AM
philwo philwo is offline
Member
 
Join Date: Aug 2006
Posts: 14
Setting both memory limits to 0 or alternatively to soft: 200M, hard: 240M "fixes" the error, setting it to a low value like 20M brings a 503 error again! Now, is this the real solution to disable memory limits or is it still a bug but disabling the limit just hides it?

Edit: I encountered the error again during a Wordpress installation with memory limits soft: 200M, hard: 240M.
Edit 2: Sorry, this may have happened because of other memory limits set in this special VHost template.. (Edit 3, yes, it was because of these limits. Removed all memory limits but soft: 200M, hard: 240M in Server -> Security -> CGI Resources -> Memory soft/hard settings and it's still running fine)

Last edited by philwo; 08-16-2006 at 11:22 AM..
Reply With Quote
  #4  
Old 08-16-2006, 04:23 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
You can set the memory limit for individual external application that needs more memory.
Reply With Quote
  #5  
Old 10-01-2006, 07:20 PM
gboudreau gboudreau is offline
Member
 
Join Date: Oct 2006
Location: Montr
Posts: 49
Using LiteSpeed 2.2.2 standard, APC 3.0.12p2 and PHP 5.1.6 LSAPI.

I am also getting
Code:
FATAL: emalloc(): Unable to allocate x bytes
in my stderr.log when I have APC enabled.
This happens when I use a self-created PHP script which loads a 8MB serialized (on disk) object and plays with it. Didn't try to see what exactly in my script made it spit this error; I would guess it errors out when loading the object.
The only way I found to make it work is to disable apc in php.ini

I tried using either 0 or high values (300M/450M) as memory soft/hard limits in both Server > Security > CGI Resource and VHost > External Apps > LSAPI App, but it didn't help al all.

Thanks for any pointer on how to resolve / debug.
__________________
- Guillaume Boudreau
Reply With Quote
  #6  
Old 10-01-2006, 07:26 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
You also need to check the memory limit set in php.ini
Reply With Quote
  #7  
Old 10-01-2006, 07:33 PM
gboudreau gboudreau is offline
Member
 
Join Date: Oct 2006
Location: Montr
Posts: 49
php.ini: memory_limit = 600M
Server > Security > CGI Resource: memory limits = 600M / 700M
VHost > External Apps > LSAPI App: memory limits = 600M / 700M

Restarted lsws to make sure the new limits were used.

Also tried 0 / 0 as memory limits.

All with same result:
FATAL: emalloc(): Unable to allocate 16 bytes
FATAL: emalloc(): Unable to allocate 16 bytes
__________________
- Guillaume Boudreau

Last edited by gboudreau; 10-01-2006 at 07:38 PM..
Reply With Quote
  #8  
Old 10-01-2006, 09:00 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
Please check your default memory limit with "ulimit -a" from command line. LSWS may not able to raise above that limit when PHP is not started in setUIDMode.
Reply With Quote
  #9  
Old 10-02-2006, 04:40 AM
gboudreau gboudreau is offline
Member
 
Join Date: Oct 2006
Location: Montr
Posts: 49
I'm using the PHP_SuEXEC template that came with 2.2.2 for this virtual host.

Code:
[root@megaone ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
max nice                        (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 8063
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
max rt priority                 (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 8063
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
file locks                      (-x) unlimited
__________________
- Guillaume Boudreau
Reply With Quote
  #10  
Old 10-02-2006, 09:42 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
Can your PHP script from command line with CLI version of PHP to make sure it is not a PHP problem?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:45 PM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.