0

I create a codigniter application with SQL server database. there is record set about 37000 records. this is the message showing when run the application. i increased the PHP.ini file as

; Maximum amount of memory a script may consume (128MB) ; http://php.net/memory-limit memory_limit=1024M

what should i do?

enter image description here

Hasee
  • 27
  • 2
  • 9
  • you need to get records in chunk like 100 records and then go for next 100..... because i don't know why you want all 37000 records in a single shot. As well as if you are using JOINS to get related data from other tables then it become even heavier. So go for chunks – Alive to die - Anant Sep 04 '18 at 05:06
  • yes, @AlivetoDie you correct. i do not need all record at once. but i need to know what should i do for when occurring such a error. – Hasee Sep 04 '18 at 05:11
  • there is no single fix for this. Only you can think logically and prevent it everywhere. Read these threads for more knowledge:- [How do you fix memory limit exceeded in competitive programing?](https://www.quora.com/How-do-you-fix-memory-limit-exceeded-in-competitive-programing) And [What kind of problems give an MLE (memory limit exceeded)?](https://www.quora.com/What-kind-of-problems-give-an-MLE-memory-limit-exceeded) – Alive to die - Anant Sep 04 '18 at 05:15
  • i think you should check your query. you apply comma `"` on table name. remove these comma `"` like this `SELECT * FROM policy` – Bilal Ahmed Sep 04 '18 at 05:19
  • https://stackoverflow.com/questions/27390793/sql-server-2008-returns-memory-limit-of-10240-kb-exceeded-for-buffered-query/27923092#27923092 – Atural Sep 04 '18 at 05:25
  • Possible duplicate of [SQL Server 2008 returns "Memory limit of 10240 KB exceeded for buffered query"](https://stackoverflow.com/questions/27390793/sql-server-2008-returns-memory-limit-of-10240-kb-exceeded-for-buffered-query) – Atural Sep 04 '18 at 05:45

1 Answers1

1

You should increase your Memory limit by editing your php.ini file

memory_limit = 512M

OR using php script including this line on the top of your script

ini_set("memory_limit","512M");

or using .htaccess you can set memory limit

php_value memory_limit 512M

php_value upload_max_filesize 120M

and then you can disable the query history. This is an undocumented but useful technique.

After database initialization:

$this->db->save_queries = FALSE;

Or by adding this code in database config file.

$db['default']['save_queries'] = FALSE;

Sachin
  • 789
  • 5
  • 18
  • he is looking for a setting called `sqlsrv.ClientBufferMaxKBSize` it has nothing todo with php's `memory_limit` option... – Atural Sep 04 '18 at 05:27