Welcome Guest, Not a member yet? Register   Sign In
DB inserts & Memory not cleared?
#1

[eluser]J3roen[/eluser]
I encountered a problem when inserting lot's of data in a mysql database.

The memory used keeps increasing every insert query, for some reason
it saves some data somewhere? Shouldn't it clear the data after every insert?

Using version 1.7.

To reproduce:
Code:
CREATE TABLE `yourdatabase`.`test` (
`id` INT NOT NULL AUTO_INCREMENT ,
`data` BLOB NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM

Code:
<?
class Test extends Controller {

    function Test()
    {
        parent::Controller();    
    }
    
    function index()
    {

        for($i = 0; $i < 200; $i++) {
            $data['data'] = file_get_contents("/path/to/some/file");
            
            $this->db->insert('test', $data);
            $image_id = $this->db->insert_id();

            echo round(memory_get_usage() / 1024 / 1024, 2) . "<br />";
            flush();
        }

    }
}
?&gt;

Produces:

Code:
2.8
3.42
<SNIP>
103.88
104.51

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 654047 bytes) in /home/websites/blabla/code/database/drivers/mysql/mysql_driver.php on line 488


Messages In This Thread
DB inserts & Memory not cleared? - by El Forum - 10-29-2008, 12:37 PM
DB inserts & Memory not cleared? - by El Forum - 10-29-2008, 01:19 PM
DB inserts & Memory not cleared? - by El Forum - 10-29-2008, 02:01 PM
DB inserts & Memory not cleared? - by El Forum - 11-05-2008, 08:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB