I’ve been battling this for quite some time, I am running a simple php script on my server, which pulls 15 days max worth of data from 6 tables, each having at most 5 columns of no more that 20 chars each column. But for some reason each time the script is run the server is reporting it to use 560 megs of ram. My host has denied any responsibility, so I am giving the benefit of the doubt and chasing my tail to try and my fault. Any suggestions or reassurances on this script would be greatly appreciated..
<?php
$json = file_get_contents('php://input');
$data = json_decode($json);
require_once('xxx');
$date = "";
if ($data === null) {
echo 'Invalid Access';
} else {
foreach ($data as $date) {
}
$tables = array('Seizures', 'medlist', 'Output', 'Feeds', 'HydKeto', 'MedLogs');
global $dbc;
$rows = array();
foreach ($tables as $table) {
if ($table != 'medlist') {
$query = "SELECT * FROM $table WHERE timestamp > '$date'";
} else {
$query = "SELECT * FROM $table WHERE status!='dc'";
}
$sth = mysqli_query($dbc, $query);
if ($sth != null) {
while($r = mysqli_fetch_assoc($sth)) {
$rows[$table][] = $r;
}
}
mysqli_free_result($sth);
}
echo json_encode($rows);
}
?>
Turns out this was a cloudLinux issue, not logging memory accurately. My Host finally admitted to it and fixed it after banging my head against the wall for 3 months.