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

Memory usage? #16

Open
CrimsonVex opened this issue Oct 1, 2015 · 1 comment
Open

Memory usage? #16

CrimsonVex opened this issue Oct 1, 2015 · 1 comment

Comments

@CrimsonVex
Copy link

If I have the following code in a managed C++/CLI project:

for (int i = 0; i < 5000; i++)
{
std::string html = HttpRequest(......);

CDocument d;
d.parse(html);
CSelection c = d.find("#something");

if (c.nodeNum() != 0)
{ ,,,, }
}

Will this cause a memory leak, as variables d and c are not being destructed? What can I do to remedy this if that's the case?

@lazytiger
Copy link
Owner

I have test the following code with valgrind

void test_issue() {
std::string html = "

1\n2\n
";
for (int i = 0; i < 5000; i++)
{

            CDocument d;
            d.parse(html);
            CSelection c = d.find("#something");
    }

}

valgrind --tool=memcheck ./example
==6641== Memcheck, a memory error detector
==6641== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==6641== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==6641== Command: ./example
==6641==
==6641==
==6641== HEAP SUMMARY:
==6641== in use at exit: 0 bytes in 0 blocks
==6641== total heap usage: 285,001 allocs, 285,001 frees, 10,925,066 bytes allocated
==6641==
==6641== All heap blocks were freed -- no leaks are possible
==6641==
==6641== For counts of detected and suppressed errors, rerun with: -v
==6641== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)

I think the result is ok.

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