-
Notifications
You must be signed in to change notification settings - Fork 10
Memory Leak #584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Memory Leak #584
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,11 +136,17 @@ protected function initFile() | |
| { | ||
| if ($this->maxFileSize > 0 && file_exists($this->filename) && filesize($this->filename) >= $this->maxFileSize) { | ||
| // need to reduce the file size | ||
| $file = file($this->filename); | ||
| $file = array_splice($file, ceil(count($file) * $this->reduceRatio)); | ||
| $reduceLen= ($this->maxFileSize< (int)ini_get('memory_limit')*1024?$this->maxFileSize:(int)ini_get('memory_limit')*1024)*$this->reduceRatio; | ||
| $size = filesize($this->filename)-$reduceLen; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please surround mathematical operators ( |
||
| $log =file_get_contents($this->filename, false, null, $size, $reduceLen ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try to be consistent with spacing. For example always surround
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also please omit the whitespace after the last argument (in this case |
||
|
|
||
| $log= explode(PHP_EOL, $log); | ||
| //delete first element (can be broken) | ||
| array_shift($log); | ||
|
|
||
| $this->filehandle = @fopen($this->filename, 'w'); | ||
| foreach ($file as $line) { | ||
| @fwrite($this->filehandle, $line); | ||
| foreach ($log as $line) { | ||
| @fwrite($this->filehandle, $line.PHP_EOL); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per the PSR-2 standard, please surround the concatenation sign (
|
||
| } | ||
| } else { | ||
| $this->filehandle = @fopen($this->filename, 'a'); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For readability it might be better to change this from the shorthand if else to the full controll structure:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A variable for
(int)ini_get('memory_limit') * 1024wouldn't also be out of place here