Comments (7)
@kirubakk Can you provide a reproduction case or example inputs that would cause this?
from libart.
One requirment we had was to have a dynamic "value" (object allocated by the module who inserted it) in the leaf node. We want to free this automatically when the tree is destroyed.
when we test the following list of key, it was easily reproduced (i reduced it to only 15 keys, but dont hacve that now)
bad_seq_keys.txt.txt
the above leave one leaf node not getting freed
from libart.
@kirubakk In that sequence it seems like there is lots of keys that are not deleted, so I would expect that there are many leaf nodes that are not freed? I'm not sure exactly what you are doing with the library, could you maybe provide a small code snippet?
from libart.
@armon I'm experiencing the same issue.
It's pretty easy to reproduce with the following example:
`START_TEST(test_art_insert)
{
art_tree t;
int res = art_tree_init(&t);
fail_unless(res == 0);
int len;
char buf[512];
FILE *f = fopen("tests/words.txt", "r");
uintptr_t line = 1;
while (fgets(buf, sizeof buf, f)) {
len = strlen(buf);
buf[len-1] = '\0';
fail_unless(NULL == art_insert(&t, (unsigned char*)buf, len, (void*)line));
fail_unless(art_size(&t) == line);
line++;
}
uintptr_t a;
a = (uintptr_t )art_search(&t, (const unsigned char *) "A", 2);
printf("Value of A: %" PRIuPTR "\n", a);
a = (uintptr_t )art_delete(&t, (const unsigned char *) "A", 2);
printf("Value of A: %" PRIuPTR "\n", a);
a = (uintptr_t )art_search(&t, (const unsigned char *) "A", 2);
printf("Value of A: %" PRIuPTR "\n", a);
res = art_tree_destroy(&t);
fail_unless(res == 0);
}
END_TEST`
$ scons && LD_LIBRARY_PATH=deps/check-0.9.8/src/.libs:. valgrind --leak-check=full ./test_runner
...
Running suite(s): art
Value of A: 1
Value of A: 1
Value of A: 0
==16772==
==16772== HEAP SUMMARY:
==16772== in use at exit: 2,784 bytes in 55 blocks
==16772== total heap usage: 845,047 allocs, 844,992 frees, 28,872,413 bytes allocated
==16772==
==16772== 1,196 (168 direct, 1,028 indirect) bytes in 1 blocks are definitely lost in loss record 31 of 31
==16772== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==16772== by 0x5043099: alloc_node (art.c:34)
==16772== by 0x5043099: add_child4 (art.c:494)
==16772== by 0x5043C2E: add_child (art.c:511)
==16772== by 0x5043C2E: recursive_insert (art.c:628)
==16772== by 0x5043C2E: art_insert (art.c:643)
==16772== by 0x400E9B: test_art_insert (test_art.c:25)
==16772== by 0x4E3EACA: tcase_run_tfun_fork (check_run.c:353)
==16772== by 0x4E3EACA: srunner_iterate_tcase_tfuns (check_run.c:166)
==16772== by 0x4E3EACA: srunner_run_tcase (check_run.c:286)
==16772== by 0x4E3EACA: srunner_iterate_suites (check_run.c:141)
==16772== by 0x4E3EACA: srunner_run_all (check_run.c:535)
==16772== by 0x400C87: main (runner.c:29)
==16772==
==16772== LEAK SUMMARY:
==16772== definitely lost: 168 bytes in 1 blocks
==16772== indirectly lost: 1,028 bytes in 28 blocks
==16772== possibly lost: 0 bytes in 0 blocks
==16772== still reachable: 1,588 bytes in 26 blocks
==16772== suppressed: 0 bytes in 0 blocks
==16772== Reachable blocks (those to which a pointer was found) are not shown.
==16772== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==16772==
==16772== For counts of detected and suppressed errors, rerun with: -v
==16772== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
100%: Checks: 1, Failures: 0, Errors: 0
So it seems that when there are manual removes from the tree, it's not properly released with the destroy method.
If this is the expected behavior, can you please specify how is it supposed to be done? I would like to be able to selectively remove some entries and then release the full tree without traversing it.
from libart.
from libart.
Thanks @kirubakk . This effectively fixes the memory leak. Regarding the casts, they are already present in latest master.
I have done a pull request #33 with this change.
from libart.
Thanks for the pull request, just merged!
from libart.
Related Issues (20)
- art_insert() should return a return code HOT 5
- Does the 52 bytes means extra space used besides the key's space? HOT 1
- Serialization HOT 1
- prefix_mismatch not considering partial_len on longer partial HOT 1
- Serializing the tree HOT 1
- Eliminate implicit padding in art_node struct HOT 1
- Crash in recursive_insert
- Node Header: MAX_PREFIX_LEN & uint8_t num_children HOT 2
- Possible to do range scans with ART ?
- art_iter_prefix depth goes over key_len
- [BUG] key_len not work with longer key
- Range scan performance
- Tag pointers to avoid node type byte HOT 1
- please review SSE instructions HOT 1
- Integer keys need byte-ordering swap?
- If libart support longest prefix match ?
- bugs for art_insert in some case HOT 1
- Is it thread safe? HOT 7
- search get null when str2 = str1 + '\0'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libart.