weak-references

Not loading an image from sd everytime (use WeakReference?)

偶尔善良 提交于 2019-12-25 02:47:32
问题 I have this list of people and each person has an avatar. There's a default avatar for everyone and later you can change it (the app saves the resized and circle-cropped image to the sd). Here's my approach: <ImageView android:id="@+id/photo_list_item" android:layout_width="70dip" android:layout_height="70dip" android:layout_marginRight="16dip" android:contentDescription="@string/avatar_descp" android:src="@drawable/defavatar" > </ImageView> This is part of the item that forms the list.

Rendering using Weak References, and the GC

北城余情 提交于 2019-12-25 00:36:41
问题 The Problem I've recently started learning C# . I am doing this through making a game (as I am quite familiar with this in C++ ). Objects that are to be drawn to the back buffer are 'registered' upon construction via an event being sent with a weak reference to the object. With C++ smart pointers being reference counted and (as a result) objects being destroyed as soon as the last reference goes out of scope, this works well for my purposes. However, in C# , this is certainly not the case.

Store references to self

北城余情 提交于 2019-12-24 20:30:28
问题 I am trying to create a network of nodes in Rust, where I want every node in the network to be aware of every other connected node. I thought that this could be done with weak Rc 's, like this: use std::cell::Cell; use std::cell::RefCell; use std::rc::Rc; use std::rc::Weak; struct Node { name: String, known_nodes: Rc<RefCell<Vec<Weak<Node>>>>, } impl Node { fn connect_to_network(&mut self) { self.known_nodes .borrow_mut() .push(Rc::downgrade(&Rc::new(*self))); } } fn main() { let known_nodes

TypeError: descriptor '__weakref__' doesn't apply to object from parent __str__ method

社会主义新天地 提交于 2019-12-24 19:26:18
问题 I have a parent class, let's call it A and a bunch of child classes, B , C , D , etc. I want to define a single __str__() method on the parent class and inside it I want to access the members of the child class via dir(self) . It works, but when I check if the name is a callable with callable(getattr(self, attr)) I get: TypeError: descriptor '__weakref__' for 'A' objects doesn't apply to 'B' object The code that raises the error is this: [attr for attr in dir(self) if not callable(getattr

AS3: Weak Listener References Not Appropriate During Initialization?

不想你离开。 提交于 2019-12-24 08:13:08
问题 as i currently understand, if an event listener is added to an object with useWeakReference set to true, then it is eligible for garbage collection and will be removed if and when the garbage collection does a sweep. public function myCustomSpriteClass() //constructor { this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener, false, 0, true); this.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener, false, 0, true); } in this case, is it not appropriate to initialize an object with

Unable to connect to celery task from a celery signal?

被刻印的时光 ゝ 提交于 2019-12-24 02:33:25
问题 I am trying to connect task2 from task_success signal from celery.signals import task_success from celery import Celery app = Celery() @app.task def task1(): return 't1' @app.task def task2(): return 't2' task_success.connect(task2, sender=task1) When I run this code, its throwing TypeError: cannot create weak reference to 'PromiseProxy' object If remove app.task decorator for task2, it works perfectly. But why is it unable to connect to celery task? 回答1: The technical details is that the

Contradiction in WeakReference's Java documentation

别来无恙 提交于 2019-12-24 02:23:32
问题 This question is about understanding the Java documentation for WeakReference When I read about Java's WeakReference, I came across this sentence in the documentation: Suppose that the garbage collector determines at a certain point in time that an object is weakly reachable. At that time it will atomically clear all weak references to that object and all weak references to any other weakly-reachable objects from which that object is reachable through a chain of strong and soft references But

Contradiction in WeakReference's Java documentation

痴心易碎 提交于 2019-12-24 02:23:13
问题 This question is about understanding the Java documentation for WeakReference When I read about Java's WeakReference, I came across this sentence in the documentation: Suppose that the garbage collector determines at a certain point in time that an object is weakly reachable. At that time it will atomically clear all weak references to that object and all weak references to any other weakly-reachable objects from which that object is reachable through a chain of strong and soft references But

Application crashes in background, when popping a fragment from stack

倾然丶 夕夏残阳落幕 提交于 2019-12-23 20:59:50
问题 Application crashes, when I hit a server RPC, and when the RPC is in progress, I put the application in background. Meanwhile, when the RPC gets the response from server, it pops a fragment from stack. While popping the fragment, the application crashes. I have read about creating WeakReference, which will be null if the activity is destroyed. But not sure how to implement it this case. Following is my code : private void showFragment(SherlockFragment fragment) { FragmentManager fm =

Create Weak Multimap with Google Collections

那年仲夏 提交于 2019-12-23 07:28:32
问题 Is there an equivalent to the nice MapMaker for MultiMaps? currently i create the cache like this: public static Map<Session,List<Person>> personCache = new MapMaker().weakKeys().makeMap(); the whole point of MultiMap is to avoid the nested List Values. is there any way to construct the multimap with weak keys? 回答1: Unfortunately not. Yet. Could you file a MultimapMaker feature request in our issues db? http://google-collections.googlecode.com 来源: https://stackoverflow.com/questions/737060