[
https://issues.apache.org/jira/browse/AVRO-210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12779673#action_12779673
]
Scott Banachowski commented on AVRO-210:
----------------------------------------
Checked the change by running unittest with valgrind.
Before patch:
==25814== definitely lost: 236 bytes in 2 blocks
==25814== indirectly lost: 720 bytes in 21 blocks
==25814== possibly lost: 0 bytes in 0 blocks
==25814== still reachable: 0 bytes in 0 blocks
==25814== suppressed: 0 bytes in 0 blocks
After patch:
==26004== All heap blocks were freed -- no leaks are possible
> Memory leak with recursive schemas when constructed by hand
> -----------------------------------------------------------
>
> Key: AVRO-210
> URL: https://issues.apache.org/jira/browse/AVRO-210
> Project: Avro
> Issue Type: Bug
> Components: c++
> Reporter: Thiruvalluvan M. G.
>
> Schema consists of a node or bunch of nodes. These nodes are represented as
> intrusive pointers of nodes (NodPtr). Since the intrusive pointers use
> reference counts, recursive schemas which result in cycles of intrusive
> pointers lead to memory leak. The following code, when compiled and run,
> causes the memory to grow steadily:
> {code:title=test.cc|borderStyle=solid}
> #include <unistd.h>
> #include "Schema.hh"
> int main(int argc, char** argv)
> {
> const int count1 = 10;
> const int count2 = 1000;
> for (int i = 0; i < count1; i++) {
> for (int j = 0; j < count2; j++) {
> avro::RecordSchema rec("LongList");
> rec.addField("value", avro::LongSchema());
> avro::UnionSchema next;
> next.addType(avro::NullSchema());
> next.addType(rec);
> rec.addField("next", next);
> rec.addField("end", avro::BoolSchema());
> }
> sleep(1);
> }
> }
> {code}
> The leak should not happen when we build the schema by parsing a JSON schema
> file. This is because the current implementation does not use pointers for
> symbolic links; it uses symbols and there is a symbol table that resolves the
> symbols at runtime. But unfortunately the nested schema file generates an
> error. I'll file a separate JIRA for that.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.