cyclic-reference

Preventing cyclic reference memory leaks in Perl

丶灬走出姿态 提交于 2019-12-06 20:27:49
问题 I recently asked a question about overwriting objects and memory management in Perl. One of the answers I received notified me that I may have an issue with a script I recently wrote. I have a script with some very complex data structures that have many parent->child / child->parent relationships. This also means that there are many objects that have cyclic references. According to this answer, cyclic references can "trick" Perl's reference counting mechanism and cause memory leaks if they

build.sbt defining project dependency between modules

醉酒当歌 提交于 2019-12-06 07:23:17
I have project in PlayFramework. It has one main project without any code/logic. And it have few submodules: main: admin common shop Modules: admin and shop will base on common module (classes like: user, role, permission), so I have to configure it that way: lazy val shop = project.in(file("modules/shop")) .dependsOn(cirs) .dependsOn(common) .dependsOn(admin) lazy val admin = project.in(file("modules/admin")) .dependsOn(cirs) .dependsOn(common) .dependsOn(shop) But in module common I have view where I wonna display links (a href...) to other submodules. To do this I have to use reverse

Maven says I have a cyclic reference in multi-module project but can't figure out why

时光怂恿深爱的人放手 提交于 2019-12-05 04:09:14
I have a multi-module project that looks like this: module1 pom.xml module2 pom.xml pom.xml The pom.xml in module2 has a dependency on module1. When I run mvn clean compile I get the following error: The projects in the reactor contain a cyclic reference. Here are my dependencies in module1: <dependencies> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.14</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch<

Preventing cyclic reference memory leaks in Perl

白昼怎懂夜的黑 提交于 2019-12-05 01:19:08
I recently asked a question about overwriting objects and memory management in Perl. One of the answers I received notified me that I may have an issue with a script I recently wrote. I have a script with some very complex data structures that have many parent->child / child->parent relationships. This also means that there are many objects that have cyclic references. According to this answer , cyclic references can "trick" Perl's reference counting mechanism and cause memory leaks if they are not dealt with properly. Example of a cyclic reference: +-------------------------------------------

What is a reference cycle in python?

爷,独闯天下 提交于 2019-11-29 09:06:40
I have looked in the official documentation for python, but i cannot seem to find what a reference cycle is. Could anyone please clarify what it is for me, as i am trying to understand the GC module. Thank you in advance for your replies. A reference cycle simply means one or more objects referencing each other, such that if you drew it out on paper with arrows representing the dependencies you would see a cycle. The (almost) simplest reference cycle is having two objects a and b that refer to each other: a.other = b b.some_attr = a Naive garbage collectors work strictly off of whether or not

shared_ptr and cyclic references

谁说我不能喝 提交于 2019-11-28 23:46:32
I was trying with the cyclic references for boost::shared_ptr , and devised following sample: class A{ // Trivial class public: i32 i; A(){} A(i32 a):i(a){} ~A(){ cout<<"~A : "<<i<<endl; } }; shared_ptr<A> changeI(shared_ptr<A> s){ s->i++; cout<<s.use_count()<<'\n'; return s; } int main() { shared_ptr<A> p1 = make_shared<A>(3); shared_ptr<A> p2 = p1; shared_ptr<A> p3 = p2; shared_ptr<A> p4 = p3; p1 = p4; // 1) 1st cyclic ref. cout<<p1.use_count()<<'\n'; p1 = changeI(p4); // 2) 2nd cyclic ref. cout<<p1.use_count()<<'\n'; // putchar('\n'); cout<<endl; } which outputs 4 5 4 ~A : 4 Is it that I've

What is a reference cycle in python?

你说的曾经没有我的故事 提交于 2019-11-28 02:26:55
问题 I have looked in the official documentation for python, but i cannot seem to find what a reference cycle is. Could anyone please clarify what it is for me, as i am trying to understand the GC module. Thank you in advance for your replies. 回答1: A reference cycle simply means one or more objects referencing each other, such that if you drew it out on paper with arrows representing the dependencies you would see a cycle. The (almost) simplest reference cycle is having two objects a and b that

shared_ptr and cyclic references

匆匆过客 提交于 2019-11-27 15:03:24
问题 I was trying with the cyclic references for boost::shared_ptr , and devised following sample: class A{ // Trivial class public: i32 i; A(){} A(i32 a):i(a){} ~A(){ cout<<"~A : "<<i<<endl; } }; shared_ptr<A> changeI(shared_ptr<A> s){ s->i++; cout<<s.use_count()<<'\n'; return s; } int main() { shared_ptr<A> p1 = make_shared<A>(3); shared_ptr<A> p2 = p1; shared_ptr<A> p3 = p2; shared_ptr<A> p4 = p3; p1 = p4; // 1) 1st cyclic ref. cout<<p1.use_count()<<'\n'; p1 = changeI(p4); // 2) 2nd cyclic ref.

shared_ptr and weak_ptr differences

▼魔方 西西 提交于 2019-11-27 05:56:21
I am reading Scott Meyers "Effective C++" book. It was mentioned that there are tr1::shared_ptr and tr1::weak_ptr act like built-in pointers, but they keep track of how many tr1::shared_ptrs point to an object. This is known as reference counting. This works well in preventing resource leaks in acyclic data structures, but if two or more objects contain tr1::shared_ptrs such that a cycle is formed, the cycle may keep each other's reference count above zero, even when all external pointers to the cycle have been destroyed. That's where tr1::weak_ptrs come in. My question is how cyclic data

Java Enums: Two enum types, each containing references to each other?

爷,独闯天下 提交于 2019-11-27 01:33:14
Is there a way to get around the class-loading issues caused by having two enums that reference each other? I have two sets of enumerations, Foo and Bar, defined like so: public class EnumTest { public enum Foo { A(Bar.Alpha), B(Bar.Delta), C(Bar.Alpha); private Foo(Bar b) { this.b = b; } public final Bar b; } public enum Bar { Alpha(Foo.A), Beta(Foo.C), Delta(Foo.C); private Bar(Foo f) { this.f = f; } public final Foo f; } public static void main (String[] args) { for (Foo f: Foo.values()) { System.out.println(f + " bar " + f.b); } for (Bar b: Bar.values()) { System.out.println(b + " foo " +