Welcome Guest, Not a member yet? Register   Sign In
Problem with a long running function in a library
#1

[eluser]Unknown[/eluser]
I have a CI library set up to create the visualisation using GD. I'm still very much in the development stages of my project and am concentrating on the image generation rather than the webapp (That comes later), so at the moment, this long running process is called from a controller and I sit and wait for a few minutes for the resulting image on the web page.

What happens is interesting, I can process about 6 months of data and it takes about 150 sec, no problems there and my logging shows exactly what is going on - a nice linear process going through each day chronologically. When I try and process a bit more, maybe 9 months worth, I see in the log that CI re-inits a load of things, and from then on things goes wrong. My library says it's processing all sorts of days that it shouldn't be and even if I close the browser window it keeps running and generating more log. As far as I can tell, the process has started again and the log is the result of both the initial process running and a new one doing the same.

What is confusing me is first, why is CI doing the re-init? And secondly, why do both processes continue to run? The constructor of my library should completely clear all the data out so even if it does run again, I would expect to see in the log just a restart of the processing from the beginning.

This is the log when everything is going OK:

Code:
DEBUG - 2011-06-09 12:58:15 --> Router Class Initialized
DEBUG - 2011-06-09 12:58:15 --> Output Class Initialized
DEBUG - 2011-06-09 12:58:15 --> Security Class Initialized
DEBUG - 2011-06-09 12:58:15 --> Input Class Initialized
DEBUG - 2011-06-09 12:58:15 --> Global POST and COOKIE data sanitized
DEBUG - 2011-06-09 12:58:15 --> Language Class Initialized
DEBUG - 2011-06-09 12:58:15 --> Loader Class Initialized
DEBUG - 2011-06-09 12:58:15 --> Helper loaded: date_helper
DEBUG - 2011-06-09 12:58:15 --> Helper loaded: format_check_helper
DEBUG - 2011-06-09 12:58:15 --> Helper loaded: colourstamp_factory_helper
DEBUG - 2011-06-09 12:58:15 --> Helper loaded: overlay_helper
DEBUG - 2011-06-09 12:58:15 --> Database Driver Class Initialized
DEBUG - 2011-06-09 12:58:15 --> Controller Class Initialized
DEBUG - 2011-06-09 12:58:15 --> Model Class Initialized
DEBUG - 2011-06-09 12:58:15 --> Model Class Initialized
INFO  - 2011-06-09 12:58:17 --> Building partial visualisation (ID: 1968273452)
INFO  - 2011-06-09 12:58:17 --> 30 days to process of total 365
INFO  - 2011-06-09 12:58:17 --> 0 days now processed
INFO  - 2011-06-09 12:58:17 --> Memory currently used 7951080 bytes
INFO  - 2011-06-09 12:58:17 --> Partial image loaded
INFO  - 2011-06-09 12:58:17 --> Processing day: 2010-01-01
INFO  - 2011-06-09 12:58:18 --> Processing day: 2010-01-02
INFO  - 2011-06-09 12:58:19 --> Processing day: 2010-01-03
... and so on
INFO  - 2011-06-09 12:59:27 --> Processing day: 2010-01-30
INFO  - 2011-06-09 12:59:30 --> Partial circle visualisation created in 73 seconds
INFO  - 2011-06-09 12:59:32 --> Building partial visualisation (ID: 1968273452)
INFO  - 2011-06-09 12:59:32 --> 27 days to process of total 365
INFO  - 2011-06-09 12:59:32 --> 30 days now processed
INFO  - 2011-06-09 12:59:32 --> Memory currently used 7441388 bytes
INFO  - 2011-06-09 12:59:33 --> Partial image loaded
INFO  - 2011-06-09 12:59:33 --> Processing day: 2010-02-01
INFO  - 2011-06-09 12:59:35 --> Processing day: 2010-02-02
INFO  - 2011-06-09 12:59:37 --> Processing day: 2010-02-03
... and so on

And this is what happens when the reinitialisation occurs:

Code:
INFO  - 2011-06-09 13:03:18 --> Processing day: 2010-06-08
INFO  - 2011-06-09 13:03:20 --> Processing day: 2010-06-09
DEBUG - 2011-06-09 13:03:20 --> Config Class Initialized
DEBUG - 2011-06-09 13:03:20 --> Hooks Class Initialized
DEBUG - 2011-06-09 13:03:20 --> Utf8 Class Initialized
DEBUG - 2011-06-09 13:03:20 --> UTF-8 Support Enabled
DEBUG - 2011-06-09 13:03:20 --> URI Class Initialized
DEBUG - 2011-06-09 13:03:20 --> Router Class Initialized
DEBUG - 2011-06-09 13:03:20 --> Output Class Initialized
DEBUG - 2011-06-09 13:03:20 --> Security Class Initialized
DEBUG - 2011-06-09 13:03:20 --> Input Class Initialized
DEBUG - 2011-06-09 13:03:20 --> Global POST and COOKIE data sanitized
DEBUG - 2011-06-09 13:03:20 --> Language Class Initialized
DEBUG - 2011-06-09 13:03:20 --> Loader Class Initialized
DEBUG - 2011-06-09 13:03:20 --> Helper loaded: date_helper
DEBUG - 2011-06-09 13:03:20 --> Helper loaded: format_check_helper
DEBUG - 2011-06-09 13:03:20 --> Helper loaded: colourstamp_factory_helper
DEBUG - 2011-06-09 13:03:20 --> Helper loaded: overlay_helper
DEBUG - 2011-06-09 13:03:20 --> Database Driver Class Initialized
DEBUG - 2011-06-09 13:03:20 --> Controller Class Initialized
DEBUG - 2011-06-09 13:03:20 --> Model Class Initialized
DEBUG - 2011-06-09 13:03:20 --> Model Class Initialized
INFO  - 2011-06-09 13:03:23 --> Building partial visualisation (ID: 663788010)
INFO  - 2011-06-09 13:03:23 --> 30 days to process of total 365
INFO  - 2011-06-09 13:03:23 --> 0 days now processed
INFO  - 2011-06-09 13:03:23 --> Memory currently used 7951080 bytes
INFO  - 2011-06-09 13:03:23 --> Partial image loaded
INFO  - 2011-06-09 13:03:23 --> Processing day: 2010-01-01
INFO  - 2011-06-09 13:03:24 --> Processing day: 2010-01-02
INFO  - 2011-06-09 13:03:24 --> Processing day: 2010-06-10
INFO  - 2011-06-09 13:03:26 --> Processing day: 2010-01-03
INFO  - 2011-06-09 13:03:27 --> Processing day: 2010-06-11
INFO  - 2011-06-09 13:03:29 --> Processing day: 2010-01-04
INFO  - 2011-06-09 13:03:29 --> Processing day: 2010-06-12

I imagine the answer is going to be to separate the library from CI and run it in the background but at this stage I'd like to udnerstand what's happening.

I hope I've given enough information to describe my problem. Anyone have any thoughts?
#2

[eluser]toopay[/eluser]
Image functions are very memory intensive.




Theme © iAndrew 2016 - Forum software by © MyBB