[ 
https://issues.apache.org/jira/browse/AVRO-210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12779548#action_12779548
 ] 

Scott Banachowski commented on AVRO-210:
----------------------------------------

Thiru,

Ah, thanks for jogging my memory.  In the previous code, once you converted 
your schema to a ValidSchema, it would walk to tree, and replace any circular 
link with a symbolic link, and break the circular dependency (keeping making 
you resolve the symbolic link in a look-aside map).

When I implemented AVRO-204, I forgot that's the reason I did that :) and 
reintroduced the circular link.

I will fix this by using weak_ptr for the symbolic link.



> 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.

Reply via email to