dev/vala/hello/memory.vala

31 lines
591 B
Vala
Raw Normal View History

2012-10-01 17:32:03 +04:00
class Node : Object {
public Node prev;
public weak Node next;
public Node (Node? prev = null) {
this.prev = prev; // ref
if (prev != null) {
prev.next = this; // ref
}
}
}
/*
void main () {
var n1 = new Node (); // ref
var n2 = new Node (n1); // ref
// print the reference count of both objects
stdout.printf ("%u, %u\n", n1.ref_count, n2.ref_count);
} // unref, unref
*/
void main () {
while (true) {
var n1 = new Node ();
var n2 = new Node (n1);
Thread.usleep (100);
}
}