Skip to content
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

Debug/Toolbar - Memory issue fix #4590

Merged
merged 2 commits into from
May 2, 2021

Conversation

najdanovicivan
Copy link
Contributor

@najdanovicivan najdanovicivan commented Apr 20, 2021

Description
This is the very simple method to avoid memory leak issue #4137 when entity objects with circular references are passed to the view.

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the concept but not the end result. We need to find some way to catch as much as we can. Does Kint (already included) not have some solution for this in place?

system/Debug/Toolbar.php Outdated Show resolved Hide resolved
system/Debug/Toolbar.php Outdated Show resolved Hide resolved
@najdanovicivan
Copy link
Contributor Author

@MGatner I managed to make Kint work inside debug bar. The issue I had is that Kint render will return JS and CSS in as the string and since those are set as text via JS. The javascript from Kint will never be executed. So I had to play a bit with it to add the JS and CSS into the page head instead and then drop those when it's being rendered in the debug bar

@MGatner
Copy link
Member

MGatner commented Apr 22, 2021

I'll take a look - if it is working then that's probably good. Kint also supports prefix modifiers to adjust the behavior - I think we could probably use ~ for "text output", or maybe @ to "return output". Play around with those and see what you think.

https://kint-php.github.io/kint/advanced/

Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be fine. It definitely adds some complexity. See what you think of the text output option and if that is a worthy trade-off.

system/Debug/Toolbar.php Outdated Show resolved Hide resolved
system/Debug/Toolbar.php Outdated Show resolved Hide resolved
system/Debug/Toolbar.php Outdated Show resolved Hide resolved
@najdanovicivan
Copy link
Contributor Author

najdanovicivan commented Apr 22, 2021

I am using @ prefix to return output. I tried text output as well but it looks nasty.

I was unable to make it work by chaining prefixes eg @~d() will not work for me.

Another problem with text output is it can get very long especially when controller is being passed to the view and if any of the variables contains HTML it may break the <pre> tag

@MGatner MGatner merged commit deb6839 into codeigniter4:develop May 2, 2021
@najdanovicivan najdanovicivan deleted the toolbar-memory-leak branch May 17, 2021 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants