Memory leak when saving an email
JWardee opened this issue · 0 comments
We are using the Mail Catcher plugin that you created. It really fits our needs, thanks.
Unfortunately, we are experiencing some memory problems lately witch we tracked down to your plugin. We were wondering if you could add a line of code to prevent this from happening.
the following code can be found in a number of places:
Logs::getFirst(['id' => $this->id])
The “getFirst” function then calls the “Get” function with the same arguments. Unfortunately the “Get” function does not support the “id” argument, this results in a query that selects alle table records and loads them in the memor. If the table has more than 30000 record, it will take up to much memory and the application will crash.
I fixed the problem by adding the following code just under the “post__in” check.
elseif (!empty($args['id'])) {
$whereClause = true;
$sql .= "WHERE id = " . $args['id'] . " ";
}
Hopefully, you can include this in the next update.
If there is another solution to this problem, it will also be appreciated