Search Results

Search found 4689 results on 188 pages for 'weak references'.

Page 1/188 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Weak hashmap with weak references to the values?

    - by Razor Storm
    I am building an android app where each entity has a bitmap that represents its sprite. However, each entity can be be duplicated (there might be 3 copies of entity asdf for example). One approach is to load all the sprites upfront, and then put the correct sprite in the constructors of the entities. However, I want to decode the bitmaps lazily, so that the constructors of the entities will decode the bitmaps. The only problem with this is that duplicated entities will load the same bitmap twice, using 2x the memory (Or n times if the entity is created n times). To fix this, I built a SingularBitmapFactory that will store a decoded Bitmap into a hash, and if the same bitmap is asked for again, will simply return the previously hashed one instead of building a new one. Problem with this, though, is that the factory holds a copy of all bitmaps, and so won't ever get garbage collected. What's the best way to switch the hashmap to one with weakly referenced values? In otherwords, I want a structure where the values won't be GC'd if any other object holds a reference to it, but as long as no other objects refers it, then it can be GC'd.

    Read the article

  • weak or strong for IBOutlet and other

    - by Piero
    I have switched my project to ARC, and I don't understand if I have to use strong or weak for IBOutlets. Xcode do this: in interface builder, if a create a UILabel for example and I connect it with assistant editor to my ViewController, it create this: @property (nonatomic, strong) UILabel *aLabel; It uses the strong, instead I read a tutorial on RayWenderlich website that say this: But for these two particular properties I have other plans. Instead of strong, we will declare them as weak. @property (nonatomic, weak) IBOutlet UITableView *tableView; @property (nonatomic, weak) IBOutlet UISearchBar *searchBar; Weak is the recommended relationship for all outlet properties. These view objects are already part of the view controller’s view hierarchy and don’t need to be retained elsewhere. The big advantage of declaring your outlets weak is that it saves you time writing the viewDidUnload method. Currently our viewDidUnload looks like this: - (void)viewDidUnload { [super viewDidUnload]; self.tableView = nil; self.searchBar = nil; soundEffect = nil; } You can now simplify it to the following: - (void)viewDidUnload { [super viewDidUnload]; soundEffect = nil; } So use weak, instead of the strong, and remove the set to nil in the videDidUnload, instead Xcode use the strong, and use the self... = nil in the viewDidUnload. My question is: when do I have to use strong, and when weak? I want also use for deployment target iOS 4, so when do I have to use the unsafe_unretain? Anyone can help to explain me well with a small tutorial, when use strong, weak and unsafe_unretain with ARC?

    Read the article

  • Weak-linking with static libraries

    - by Jaakko L.
    I have declared an external function with a GCC weak attribute in a .c file: extern int weakFunction( ) __attribute__ ((weak)); Compiled object file has weakFunction defined as a weak symbol. Output of nm: 1791: w weakFunction I am calling the weak defined function as follows: if (weakFunction != NULL) { weakFunction(); } When I link the program by defining the object files as parameters to GCC (gcc main.o weakf.o -o main.exe) weak symbols work fine. If I leave the weakf.o out of linking, the function address is NULL in main.c and the function won't be called. Problem is, when weakf.o is inside a static library, for some reason the linker doesn't find the function and the function address always ends up being NULL. Static library is created with ar: ar rcs weaklibrary weakf.o Anyone had similar problems?

    Read the article

  • VS2008 VB project - Changing application type automatically adds references

    - by Stijn
    Visual Basic Create a new project with the Empty Project template (Visual Basic - Windows) Go to the project properties, and change the Application type by choosing something else or reselecting Windows Forms Application. When reselecting, Visual Studio will automatically add references to System.Deployment, System.Drawing and System.Windows.Forms C# Create a new project with the Empty Project template (Visual C# - Windows) Go to the project properties, and change the Application type to any of the choices. Visual studio will not add references. Question Is there a way to change this behaviour for Visual Basic?

    Read the article

  • When to use weak references in Python?

    - by bodacydo
    Can anyone explain usage of weak references? The documentation doesn't explain it precisely, it just says that the GC can destroy the object linked to via a weak reference at any time. Then what's the point of having an object that can disappear at any time? What if I need to use it right after it disappeared? Can you please explain them with some good examples? Thanks, Boda Cydo.

    Read the article

  • Good references to know why has my computers stopped responding me

    - by Peterstone
    Hello all! I´m a windows xp user (but not for much time...) and I usually see how my computer stop of responding me. The process is this: Firsly it became totally stopped or very slow for certain periods of 5 minutes. How could I do? After that it gets stopped (Even not totally because If I click on the bar I see a blinking response in the bar botton of the program I click on. It´s could be anything related with security (like the firewall or some virus)? Computer university: I usually experience this, using Matlab (R2007a) with System Generator (its respective compatible version) My personal laptop: It´s usually works well but when stopped periods became to appears I know in not much time it will became totally stopped. I usually see how Word 2007 get stopped and after a while my windows xp gets stopped. (well I can access to the the manage task pressing ctr+alt and...). The only solution I see is to kill program by program... My petition: Please, I need good references that help me how to think in order to avoid or to manage the problems previously described. Does anyone know usefull books or articles? EDIT: Laptop: OS: XP Home Edition Version 2002 SP3 Hardware: HP Mini Intel(R)Atom(TM) CPU N270 @1,60GHz 1.99 GB RAM University Computer: OS: XP Profesional SP3 Hardware: AMD Athlon(tm) XP 1800+ 1.54 GHz, 768 MB RAM

    Read the article

  • Alternatives to weak linking in iPhone SDK?

    - by Moshe
    I'm looking to make my app compatible with older versions of iPhone OS. I did see weak linking mentioned as an option. Can I use OS version detection code to avoid code blocks that the OS can't handle? (Say iAD?) if(OS >= 4.0){ //set up iADs using "NDA code"... } If yes, what goes in place of if(OS >= 4.0)?

    Read the article

  • Does weak typing offer any advantages?

    - by sub
    Don't confuse this with static vs. dynamic typing! You all know JavaScripts/PHPs infamous type systems: PHP example: echo "123abc"+2; // 125 - the reason for this is explained // in the PHP docs but still: This hurts echo "4"+1; // 5 - Oh please echo "ABC"*5; // 0 - WTF // That's too much, seriously now. // This here might be actually a use for weak typing, but no - // it has to output garbage. JavaScript example: // A good old JavaScript, maybe you'll do better? alert("4"+1); // 51 - Oh come on. alert("abc"*3); // NaN - What the... // Have your creators ever heard of the word "consistence"? Python example: # Python's type system is actually a mix # It spits errors on senseless things like the first example below AND # allows intelligent actions like the second example. >>> print("abc"+1) Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> print("abc"+1) TypeError: Can't convert 'int' object to str implicitly >>> print("abc"*5) abcabcabcabcabc Ruby example: puts 4+"1" // Type error - as supposed puts "abc"*4 // abcabcabcabc - makes sense After these examples it should be clear that PHP/JavaScript probably have the most inconsistent type systems out there. This is a fact and really not subjective. Now when having a closer look at the type systems of Ruby and Python it seems like they are having a much more intelligent and consistent type system. I think these examples weren't really necessary as we all know that PHP/JavaScript have a weak and Python/Ruby have a strong type system. I just wanted to mention why I'm asking this. Now I have two questions: When looking at those examples, what are the advantages of PHPs and JavaScripts type systems? I can only find downsides: They are inconsistent and I think we know that this is not good Types conversions are hardly controllable Bugs are more likely to happen and much harder to spot Do you prefer one of the both systems? Why? Personally I have worked with PHP, JavaScript and Python so far and must say that Pythons type system has really only advantages over PHPs and JavaScripts. Does anybody here not think so? Why then?

    Read the article

  • OSX Weak Linking - check if a class exists and use that class

    - by psychotik
    I'm trying to create a universal iPhone app, but it uses a class defined only in a newer version of the SDK. The framework exists on older systems, but a class defined in the framework doesn't. I know I want to use some kind of weak linking, but any documentation I can find talks about runtime checks for function existence - how do I check that a class exists?

    Read the article

  • Visual Studio 2010 Solution Find all References Not Working

    - by Jeremiah
    I have a Visual Studio 2010 Solution that was imported from a Visual Studio 2008 solution that the Find all References does not work on. I've tried doing some searches on Google to try and figure this out but have come up empty handed. The find all references in VS2008 worked like a charm, we upgraded to 2010 and now no matter what file I'm in the Find All References doesn't return anything. Anyone have any idea how to possibly fix this or some good ways to "debug" the issue.

    Read the article

  • Simple Data Caching using Weak References in WCF

    - by Tawani
    Given that I have the following WCF service: class LookUpService { public List<County> GetCounties(string state) { var db = new LookUpRepository(); return db.GetCounties(state); } } class County { public string StateCode{get;set;} public string CountyName{get;set;} public int CountyCode{get;set;} } What will be the most efficient (or best) way to cache a state's counties using weak references (or any other approach) so that we don't hit the database every time we need to look up data. Note that we will not have access to the HttpRuntime (and HttpContext).

    Read the article

  • Static/Dynamic vs Strong/Weak

    - by Dan Revell
    I see these terms banded around all over the place in programming and I have a vague notion of what they mean. A search shows me that such things have been asked all over stack overflow in fact. As far as I'm aware Static/Dynamic typing in languages is subtly different to Strong/Weak typing but what that difference is eludes me. Different sources seem to use different different meanings or even use the terms interchangeably. I can't find somewhere that talks about both and actually spells out the difference. What would be nice is if someone could please spell this out clearly here for me and the rest of the world.

    Read the article

  • AS3: Weak Listener References Not Appropriate During Initialization?

    - by TheDarkIn1978
    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 weak references event listeners, incase the garbage collector does activate a sweep removing the objects event listeners since they were added during initialization of the object? in this case, would it only be appropriate to create a type of deallocate() method which removes the event listeners before the object is nullified?

    Read the article

  • How to avoid XCode framework weak-linking problems?

    - by Frank R.
    Hi, I'm building an application that takes advantage of Mac OS X 10.6-only technologies, but without giving up backwards compatibility to 10.5 Leopard. The way I do this is by setting the 10.6 SDK as the base SDK, weak-linking all frameworks and setting the deployment target to 10.5 as described in: http://developer.apple.com/mac/library/DOCUMENTATION/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html This works fine; before making a call that is Snow Leopard-only I need to check that the selector or indeed the class actually exist. Or I can just check the OS version before making the call. The problem is that this is incredibly fragile. If I make a single call that is 10.6 only I blow Leopard-compatibility. So using even the normal code code completion feature can be dangerous. My question: is there any way of checking which calls are not defined on 10.5 before doing a release build? Some kind of static analysis, or even just a trick (a target set the other SDK?) would do. I obviously should test on a Leopard machine before releasing anything, but even so I can't possibly go through all paths of the program before every release. Any advice would be appreciated. Best regards, Frank

    Read the article

  • MSBuild: building website using AspNetCompiler - adding references?

    - by Tom Morgan
    Hi, I'm attempting to build a ASP.NET website using MSBuild - specifically the AspNetCompiler tag. I know that, for my project, I need to add some references. Within Visual Studio I have several references, one is a project reference and the others are some DLLS (AjaxControlToolkit etc). I'm happy not referencing the project and referencing the DLL instead - however I just can't work out how to add a reference. I've looked up and down and this is what I've found so far: <Target Name = "PrecompileWeb"> <AspNetCompiler VirtualPath = "DeployTemp" PhysicalPath = "D:\AutoBuild\CruiseControl\Projects\Websites\MyCompany\2.0.0\WorkingDirectory\VSS" TargetPath = "D:\AutoBuild\CruiseControl\Projects\Websites\MyCompany\2.0.0\PreCompiled" Force = "true" Debug = "true" Updateable = "true"/> </Target> Also - I've picked up this bit of code from around the web somewhere, which I thought might help: <ItemGroup> <Reference Include="My.Web.DataEngine, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>D:\AutoBuild\CruiseControl\Projects\Components\My.Web.DataEngine\bin\Debug\My.Web.DataEngine.dll</HintPath> </Reference> </ItemGroup> What I want to do is add a attribute to the AspNetCompiler tag, something like: References="@(Reference)" but MSBuild isn't very happy about this. I've been a bit stuck in not being able to find decent references on doing this anywhere: so I'd really apprechiate some pointers or reference material etc. (or just the answer!) Thanks for you help. -tom

    Read the article

  • Matching .NET References to Namespaces

    - by maxp
    This seems confusing to me - im creating a class library, and adding all the necessary references for the source files contained in it. Now, off the bat, there were over 300 compiler errors complaining about missing namespaces. The library will now compile after i just added all of the System.* references, however this is obviously not the best way. I.e. if a classes needs using System.Web.Script;, there is no System.Web.Script reference, how would i find out which one of these references contained it? System.Web didnt.

    Read the article

  • VS2008 VB project - Changing application type automatically adds references

    - by Stijn
    Visual Basic Create a new project with the Empty Project template (Visual Basic - Windows) Go to the project properties, and change the Application type by choosing something else or reselecting Windows Forms Application. When reselecting, Visual Studio will automatically add references to System.Deployment, System.Drawing and System.Windows.Forms C# Create a new project with the Empty Project template (Visual C# - Windows) Go to the project properties, and change the Application type to any of the choices. Visual studio will not add references. Question Is there a way to change this behaviour for Visual Basic?

    Read the article

  • Refreshing Visual Studio's COM references tab

    - by r_honey
    I right-clicked on the bin folder of my web app to add a COM Reference. I did not find the desired Com reference in the list. I went back to the Command Line to register by desired Com dll using resvr32. However, the COM references tab does not shows it (looks like the information is cached somewhere). Even restarting VS did not help. Is their any easy way to refresh the COM references tab without rebooting the machine itself??

    Read the article

  • php/mongodb: how does references work in php?

    - by harald
    hello, i asked this in the mongodb user-group, but was not satisfied with the answer, so -- maybe someone at stackoverflow can enlighten me: the question was: $b = array('x' => 1); $ref = &$b; $collection->insert($ref); var_dump($ref); $ref does not contain '_id', because it's a reference to $b, the handbook states. (the code snippet is taken from the php mongo documentation) i should add, that: $b = array('x' => 1); $ref = $b; $collection->insert($ref); var_dump($ref); in this case $ref contains the _id -- for those, who do not know, what the insert method of mongodb-php-driver does -- because $ref is passed by reference (note the $b with and without referencing '&'). on the other hand ... function test(&$data) { $data['_id'] = time(); } $b = array('x' => 1); $ref =& $b; test($ref); var_dump($ref); $ref contains _id, when i call a userland function. my question is: how does the references in these cases differ? my question is probably not mongodb specific -- i thought i would know how references in php work, but apparently i do not: the answer in the mongodb user-group was, that this was the way, how references in php work. so ... how do they work -- explained with these two code-snippets? thanks in advance!!!

    Read the article

  • Why are references compacted inside Perl lists?

    - by parkan
    Putting a precompiled regex inside two different hashes referenced in a list: my @list = (); my $regex = qr/ABC/; push @list, { 'one' => $regex }; push @list, { 'two' => $regex }; use Data::Dumper; print Dumper(\@list); I'd expect: $VAR1 = [ { 'one' => qr/(?-xism:ABC)/ }, { 'two' => qr/(?-xism:ABC)/ } ]; But instead we get a circular reference: $VAR1 = [ { 'one' => qr/(?-xism:ABC)/ }, { 'two' => $VAR1->[0]{'one'} } ]; This will happen with indefinitely nested hash references and shallowly copied $regex. I'm assuming the basic reason is that precompiled regexes are actually references, and references inside the same list structure are compacted as an optimization (\$scalar behaves the same way). I don't entirely see the utility of doing this (presumably a reference to a reference has the same memory footprint), but maybe there's a reason based on the internal representation Is this the correct behavior? Can I stop it from happening? Aside from probably making GC more difficult, these circular structures create pretty serious headaches. For example, iterating over a list of queries that may sometimes contain the same regular expression will crash the MongoDB driver with a nasty segfault (see https://rt.cpan.org/Public/Bug/Display.html?id=58500)

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >