Memory limit Question

Status
Not open for further replies.

chief

New Member
Messages
78
Reaction score
0
Points
0
what is the memory limit in M, right now my server is getting suspended all the time for overusing the memory lol, and well i an tell it the memory limit in M (megabytes i think).....
 

Tomcenc

New Member
Messages
57
Reaction score
0
Points
0
On absolut PHP advanced (V3) it is limited to 128MB ram. But if you get suspended because of high resource usage it isn't only ram that counts, but also how much processor your script uses. If you want to know how resource heavy a script is, you can monitor the time it takes to generate and the peak ram usage.

Top of php:
PHP:
$starttime = explode(' ', microtime()); $starttime = $starttime[1] + $starttime[0];
Bottom of php:
PHP:
$loadtime = explode(' ', microtime()); $loadtime = $loadtime[0]+$loadtime[1]-$starttime; echo 'Page generated in ',round($loadtime, 2),' seconds. Peak memory usage: ',round(memory_get_peak_usage()/1048576, 2), 'MB';

If you use a lot of ram and little time, it's fine, if you take long time but little ram, it's not so good, if you use both high ram and long time, you probably know why you get suspended. Try putting a few times unset() in your script for variables you don't need anymore for example if I have at the top an array of a few thousand elements eating a lot of ram, but don't need it anymore in the middle, I can use unset($arrayname). If you have a "for" statement with an echo in it, put ob_start(); in front of it and ob_end_flush(); on the end. Replace "." by "," when you don't need to merge several parts, like in the above example above. Use ' instead of " to mark the start and end of something. This should improve the performance of yours scripts slightly and is applicable in almost every script.

Examples:
This is the same: (last is faster)
PHP:
echo "this"."this".$this;
echo 'this','this',$this;
This is the same: (last is faster)
PHP:
for($i=0;$i<500;$i++) {echo "something";}
ob_start(); for($i=0;$i<500;$i++) {echo 'something';}; ob_end_flush();
 
Last edited:

aneotoena

New Member
Messages
798
Reaction score
0
Points
0
I think the suspension script works with percentage of resources and mixing not only memory resources but bandwith and cpu use.
 

chief

New Member
Messages
78
Reaction score
0
Points
0
but, what is the memory limit?....my server keeps trying to raise the limit because it thinks it has 64 M, what is the limit in M for it?
Edit:
OK BUT.....i can help with it right now by telling my game server it only has the ammount it has instead of letting it think it has 64M and it should make it run a little more efficently with the resources alloted to me....so what is the memory limit set at????
 
Last edited:

chief

New Member
Messages
78
Reaction score
0
Points
0
Does any 1 know the memory limit??? on stoli? corperate hosting package
 
Last edited:

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Are you referring to PHP's memory limit?

PHP v1 has a memory_limit of 8 MB.
PHP v2 has a memory_limit of 32 MB.
PHP v3 has a memory_limit of 128 MB.

That is for all servers, Ad-Free and Ad-Enhanced hosting.

If you have a need for a memory_limit greater than v2's, 32 MB, request it and we can raise the memory_limit a bit for you.
 
Last edited:

chief

New Member
Messages
78
Reaction score
0
Points
0
ok thanks bryon, but i think after some research on my part my server will run better (and hopefully decrease the resouce usage i think it will tho) if i upgrade to advanced i have requested the upgrade stating something like that, do you know if i have a chance at getting it?
 
Status
Not open for further replies.
Top