1

I've been testing creating charts in teechart for PHP using a while loop to create multiple charts via a function:

while () {
    create_my_chart();
}

After 14 iterations of this I'm getting the following error:

"Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 800 bytes) in tchart\sources\GraphicsGD.php on line 602"

This implies that teeChart is not freeing memory correctly but I wondered if there is anything I can do about it?

KDavies
  • 23
  • 3
  • For `teeChart is not freeing memory correctly`, write a bug report and send it to them. It is a payed extention!! – JustOnUnderMillions Apr 03 '17 at 13:28
  • Please arrange a [simple example](http://stackoverflow.com/help/mcve) we can run as-is here. – Yeray Apr 03 '17 at 13:31
  • @Yeray For teeChart are only free-trails available. You have to pay for it. – JustOnUnderMillions Apr 03 '17 at 13:33
  • @Yeray Sorry, didn't notice the second string of replies. At the moment I'm using the "free for personal use" version until I know it can do what we need. If it turns out that it can then we'll buy at as it will be a bit of a bargain for what we want to achieve. – KDavies Apr 03 '17 at 14:15
  • In order to find and correct the memory leak, it would be helpful to get a simple example project we can run as-is to reproduce the problem here. You can file a new ticket at [bugzilla](http://bugs.teechart.net/). – Yeray Apr 05 '17 at 07:08

1 Answers1

0

Your allowed memory useage seems to be only 64MB. This is very small! Change it in the php.ini or do ini_set('memory_limit','1G') in the script to allow 1 GB memory. And test again.

http://php.net/manual/en/ini.core.php#ini.memory-limit

JustOnUnderMillions
  • 3,741
  • 9
  • 12
  • I've tried that but it seems to have had no effect. I echoed memory_get_usage through each iteration with the following results: 12072208, 18087936, 21757952, 25427968, 29097984, 32768000, 36438016, 39845888, 43778048, 47448064, 51118080, 54788096, 58458112, 62128128, 65798144 which I think indicated something isn't begin freed up by teechart. – KDavies Apr 03 '17 at 13:29
  • @KDavies Try `gc_enable()` before the while and after teh function `gc_collect_cycles()` in the while. if that wont work write a bug report. Also you can go into the error part and `unset()` varaibles that are not needed anymore in GraphicsGD.php. – JustOnUnderMillions Apr 03 '17 at 13:31
  • I've added the gf_enable() and gc_collect_cycles() which made no difference, I'll take a look at GraphicsGD and report back. Thanks for the suggestion. – KDavies Apr 03 '17 at 13:36
  • 1
    You definitely pointed me in the right direction. Line 13 of TChart.php contained ini_set("memory_limit","64M"); which obviously overrode my own settings. Upped it to 1G and it's certainly improved matters. The worry is that this change is compensating for a bug in tChart which will just crop up again after more iterations. Many thanks for your help. – KDavies Apr 03 '17 at 13:44
  • @KDavies Always nice to help :-) – JustOnUnderMillions Apr 03 '17 at 13:46