Use of codeigniter memory

Asked

Viewed 329 times

1

I made my first application in codeigniter, at first it was working all right. However when I looked at the server memory, it is very high, it starts with little use, and with each request it increases the use and does not release more. I don’t know what to do at the moment. I’ve used the code $db['default']['save_queries'] = FALSE;

But it didn’t work, I added the code

function __destruct() {
    unset($this);
}

to try to free up the memory used in $this, but it didn’t do much good either.

Any idea how to release the memory used?

Thank you

  • it would be good to make a Profiling of the application, I have a question about it, so far only know zend studio as a good tool http://answall.com/questions/28784/profiling-php-debug-tempo-de-execu%C3%A7%C3%A3o

  • I’ve seen the Codeigniter give a few bugs anyway. For example: I’ve done a test, sending great data via POST (form) in a system Codeigniter, and the same generated a fatal error (memory exhaustion).

  • Instead of unset($this), tries to trade for $this->db->close() in the main model :)

3 answers

1

I have also had problems with excess memory usage and wrote this short cycle to free everything at the end of each application load.

Do print_r of memory_get_usage()and memory_get_peak_usage() to see the before and after running the cycle:

// DEVELOPMENT
print_r(memory_get_usage()); echo '<br>'; // Antes
print_r(memory_get_peak_usage()); echo '<br>';

foreach (array_keys(get_defined_vars()) as $var){
    unset($$var);
}

// DEVELOPMENT
print_r(memory_get_usage()); echo '<br>'; // Depois

0

This memory overflow can be the automatic saving of the last query, you can use $this->db->save_queries = false; or change the config/database.php file to 'save_queries' => FALSE,

0

Look I think it may be the way it was developed, the CI makes many includes. the more $this->load use the more memory will consume.

But it also has to see if the memory consumption is php or database.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.