开发者

Does Z3_ast reference counting count references outside Z3?

In Z3 there are 2 modes: automatic reference counting and manual.

I understand how manual ref counting works. Thanks to example.

But how does Z3 know when to delete AST node in automatic ref-counting case? Since Z3_as开发者_如何学Got is a struct from C language => it is impossible to track all assignments and usages of Z3_ast outside Z3 after it was created.

Or Z3 track references inside Z3 only? That is no updates to ref counters are made if you do for example: ast1 = ast2.


The automatic mode uses a very simple policy. Whenever an AST is returned to the user, Z3 stores it on a stack S and increments its reference counter. When the Z3_push function is executed, Z3 saves the size of the stack S. When the matching Z3_pop is executed, the size of the stack S is restored, and the reference counter of the ASTs popped from the stack is decremented. This mode is very easy to use, but it has a main problem: memory consumption. For example, if Z3_push and Z3_pop are not used, then all ASTs created by the user will never be deleted.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜