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

Diff two JSON files #84

Open
WyriHaximus opened this issue Dec 17, 2018 · 5 comments
Open

Diff two JSON files #84

WyriHaximus opened this issue Dec 17, 2018 · 5 comments

Comments

@WyriHaximus
Copy link
Contributor

Attempting to hunt down a memory leak using the following code:

meminfo_dump(fopen('before.json', 'w'));
echo gc_collect_cycles();
meminfo_dump(fopen('after.json', 'w'));

Now I can't easily compare those two files. A diff command would be a great addition to see what has changed.

@BitOne
Copy link
Owner

BitOne commented May 3, 2019

If you have a difference between the 2 files, then there's a bug in phpMeminfo or a bug in the Zen engine.

When you cal gc_collect_cycles(), it triggers the circular collection sooner. But in all cases, the circular collection would have collected the cycles without references.

And as phpMeminfo is built to provide information on memory leak, that is items that have still reference so they cannot be cleaned up from memory, it doesn't make much sense to list items that will be collected and cleanup automatically by the Zend engine.

So there should not be any difference between the two files.

@BitOne BitOne closed this as completed May 3, 2019
@BitOne
Copy link
Owner

BitOne commented May 3, 2019

Maybe if you tell me what you want to know exactly, we could find a real solution for you case ?

@BitOne BitOne reopened this May 3, 2019
@WyriHaximus
Copy link
Contributor Author

When you cal gc_collect_cycles(), it triggers the circular collection sooner. But in all cases, the circular collection would have collected the cycles without references.

Yeah so I've learned since opening this issue.

And as phpMeminfo is built to provide information on memory leak, that is items that have still reference so they cannot be cleaned up from memory, it doesn't make much sense to list items that will be collected and cleanup automatically by the Zend engine.

So there should not be any difference between the two files.

To find a memory leak I want to see the differences between two or more files. See the exact differences and what items are new or removed between files.

@BitOne
Copy link
Owner

BitOne commented May 7, 2019

Hey @WyriHaximus ,

Thanks for your answer!

When I need to do that, I usually used the summary analyzer and the diff command to see which kind of objects leaked the most. But it's maybe not precise enough for your use case.

As we are using JSON files, maybe you can try some generic JSON tools, like jd: https://github.com/josephburnett/jd#command-line-usage

It's capable of diffing two different json files.

Don't hesitate to share your experience with it, it may help others, and we could add a section in the documentation about it, if it's worth it.

@WyriHaximus
Copy link
Contributor Author

WyriHaximus commented May 7, 2019

That is a good one. Haven't thought of that 👍 , will give it a try and report back

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

No branches or pull requests

2 participants