logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 04-17-2013, 09:03 AM   #1
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,176
Default script memory

having a nightmare while trying to intergrate a script. im getting the failure
Fatal error: Allowed memory size of 314572800 bytes exhausted (tried to allocate 35 bytes) in C:\wamp\www\dateline\init.php on line 33

originally it was lower but i have increased memory size in php.inii to a crazy 300 meg but getting same warning, i also tied adding ini_set("memory_limit","300M"); but getting no where.
Any clues anybody??
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 04-19-2013, 03:22 AM   #2
jmichae3
 
Join Date: Dec 2010
Posts: 366
Default

did you mean php.ini rather than php.inii?

lessee: I am not sure if PHP interprets that memory parameter in terms of IEC units or in terms of SI units (ahh, got it's it's IEC units), so in case it's SI units, try bumping it to 400M(400MiB) - or 700M - for now you are only testing limits - you can change it down later.
I don't know how large the scripts are or how big your data queries are. I have one script that's 75K in size and it consumes 101-104MB.

there is echo memory_get_peak_usage();
so set it really high, insert the above and then you can tune it later. all I did was think: hmm, I wonder if there are any memory functions in there? so I looked in the php .chm manual index and types in memory and came up with this nice function.

only thing you should really trust in is that peak ram usage function. I wouldn't cut it too close though, since there are dynamic things (such as database queries memory usage, forms, etc) when it comes to scripting. and there is no deallocator. just gc (garbage collection).
__________________
------------
Jim Michaels
HTML Code:
improperly<strong>nested<em>elements</strong>cause</em>
browser confusion (I believe the term is 'tag soup')!

Last edited by jmichae3; 04-19-2013 at 03:40 AM..
jmichae3 is offline   Reply With Quote
Old 04-19-2013, 03:35 AM   #3
jmichae3
 
Join Date: Dec 2010
Posts: 366
Default

got the stats from my other file.
Peak Ram Usage: 4079168
filesize: 75336

the first file was also about 75k but used about 104MB.
__________________
------------
Jim Michaels
HTML Code:
improperly<strong>nested<em>elements</strong>cause</em>
browser confusion (I believe the term is 'tag soup')!

Last edited by jmichae3; 04-19-2013 at 03:39 AM.. Reason: removal of ratio
jmichae3 is offline   Reply With Quote
Old 04-22-2013, 04:39 AM   #4
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,176
Default

thanks, i didnt really want to get beyond that. it is an inherited script fr a chat plugin. i worked around it for now but it is not sure that the project will happen now. i would like to get to the bottom of this. I suspect there is an endless loop causing problems here as it pertains to gathering member names form a db. i will return to it but posted incase there is was a magic bullet that would sort it

thank you for that function i had not heard of that
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 04-22-2013, 08:00 AM   #5
jmichae3
 
Join Date: Dec 2010
Posts: 366
Default

ahh... this can be usually be traced to
- infinite recursion (a function that calls itself with no limits, can be a tree walking function such as DOM walker that is broken)
- mutual recursion (a function which calls another function which calls the first function, with no limiting factor)
- ginormous (100k-to-1M-row) table queries? i.e. selecting the entire MAXMIND GEOIP IP table because you forgot to include a conditional in the WHERE clause of your SQL

the recursion can be in something object-opriented, such as methods in a class that have not been fully debugged.
if the package is from a 3rd party, report the bug to the author(s) so they can fix it.

if you can provide a patch, even better. usually patches are submitted using either diff or the patch tool I think (still somewhat of a mystery to me, I should ask one of these times when I think about it).

if this thing just consumes all the memory you have got and then crashes or dies at whatever limit, you have a recursion problem most likely.

this is because when you call a function, its parameters and local variables are pushed on the stack. when it calls itself repeatedly, well, you get the picture - the STACK blows up out of proportion and chews up all available memory.

if there were no limit, it would crashdump/coredump/SIGFAULT/etc. this is my guess as to why php has a memory limit on its scripts - for security reasons. you can't have a bad script causing a bunch of crashdumps that take forever on a big-memory server.

but I digress.
__________________
------------
Jim Michaels
HTML Code:
improperly<strong>nested<em>elements</strong>cause</em>
browser confusion (I believe the term is 'tag soup')!
jmichae3 is offline   Reply With Quote
Old 04-22-2013, 08:54 AM   #6
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,176
Default

yes indeed i suspect it is an included class but suspect it will be a lost cause, in he mean time i visited the developers site and it is very very slow to load and i am not convinced there is any real support. i will push this onto a back burner for now for when i have both more need and patience for it
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 05-06-2013, 07:11 PM   #7
mangofreak
mangofreak's Avatar
 
Join Date: Jan 2006
Location: Toronto-Canada
Posts: 444
Default

One time I got similar error on Moodle. The problem was an empty line where there were not supposed to be any. I deleted the empty line and the memory size problem was gone.
__________________
J.
DW | FW | HTML | CSS | ASP | some PHP | Windows | Ubuntu
mangofreak is offline   Reply With Quote
Old 05-07-2013, 02:22 AM   #8
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,176
Default

that sounds interesting . i can only hope as tthe project might just be on a gain
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 05-08-2013, 06:57 AM   #9
jmichae3
 
Join Date: Dec 2010
Posts: 366
Default

I want to dig further into this is I may, for future reference. perhaps you can submit a bug to php? or I could, if they will take it.

in what was the blank line? for instrance, was it in:
- echo
- heredoc
- '' string
- "" string (this can be on multiple lines by the way, this is how I layout my SQL statements in a nicely formatted way rarther than using a heredoc)
- between statements
- between expression parts
- between conditional parts, say, in an if, while
- between the 3 sections in a for loop
- before the php tags
- after the php tags
- before the start php tag
- after the start php tag
- before the end php tag
- after the end php tag
- ???

where?
thanks. I tend to try to help others with the info I get, so it's not just for me.
__________________
------------
Jim Michaels
HTML Code:
improperly<strong>nested<em>elements</strong>cause</em>
browser confusion (I believe the term is 'tag soup')!
jmichae3 is offline   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. The time now is 12:07 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com