Search Results

Search found 6189 results on 248 pages for 'garbage collection'.

Page 6/248 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Collection, which method is used to authorize an add of an element ?

    - by Duke Vador
    We find a lot of concrete subclasses under Collection. While trying to add an element in a concrete collection, this collection will use a method to determine if it can accept to store the element (and eventually that this element is not already in the collection). It could use equals(), hashCode() or compareTo() of the element. Is it possible to find a summary about which method is used by each implementation of Collection ? Thanks a lot for your answers.

    Read the article

  • Automatic Properties, Collection Initializers, and Implicit Line Continuation support with VB 2010

    - by ScottGu
    [In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu] This is the eighteenth in a series of blog posts I’m doing on the upcoming VS 2010 and .NET 4 release. A few days ago I blogged about two new language features coming with C# 4.0: optional parameters and named arguments.  Today I’m going to post about a few of my favorite new features being added to VB with VS 2010: Auto-Implemented Properties, Collection Initializers, and Implicit Line Continuation support. Auto-Implemented Properties Prior to VB 2010, implementing properties within a class using VB required you to explicitly declare the property as well as implement a backing field variable to store its value.  For example, the code below demonstrates how to implement a “Person” class using VB 2008 that exposes two public properties - “Name” and “Age”:   While explicitly declaring properties like above provides maximum flexibility, I’ve always found writing this type of boiler-plate get/set code tedious when you are simply storing/retrieving the value from a field.  You can use VS code snippets to help automate the generation of it – but it still generates a lot of code that feels redundant.  C# 2008 introduced a cool new feature called automatic properties that helps cut down the code quite a bit for the common case where properties are simply backed by a field.  VB 2010 also now supports this same feature.  Using the auto-implemented properties feature of VB 2010 we can now implement our Person class using just the code below: When you declare an auto-implemented property, the VB compiler automatically creates a private field to store the property value as well as generates the associated Get/Set methods for you.  As you can see above – the code is much more concise and easier to read. The syntax supports optionally initializing the properties with default values as well if you want to: You can learn more about VB 2010’s automatic property support from this MSDN page. Collection Initializers VB 2010 also now supports using collection initializers to easily create a collection and populate it with an initial set of values.  You identify a collection initializer by declaring a collection variable and then use the From keyword followed by braces { } that contain the list of initial values to add to the collection.  Below is a code example where I am using the new collection initializer feature to populate a “Friends” list of Person objects with two people, and then bind it to a GridView control to display on a page: You can learn more about VB 2010’s collection initializer support from this MSDN page. Implicit Line Continuation Support Traditionally, when a statement in VB has been split up across multiple lines, you had to use a line-continuation underscore character (_) to indicate that the statement wasn’t complete.  For example, with VB 2008 the below LINQ query needs to append a “_” at the end of each line to indicate that the query is not complete yet: The VB 2010 compiler and code editor now adds support for what is called “implicit line continuation support” – which means that it is smarter about auto-detecting line continuation scenarios, and as a result no longer needs you to explicitly indicate that the statement continues in many, many scenarios.  This means that with VB 2010 we can now write the above code with no “_” at all: The implicit line continuation feature also works well when editing XML Literals within VB (which is pretty cool). You can learn more about VB 2010’s Implicit Line Continuation support and many of the scenarios it supports from this MSDN page (scroll down to the “Implicit Line Continuation” section to find details). Summary The above three VB language features are but a few of the new language and code editor features coming with VB 2010.  Visit this site to learn more about some of the other VB language features coming with the release.  Also subscribe to the VB team’s blog to learn more and stay up-to-date with the posts they the team regularly publishes. Hope this helps, Scott

    Read the article

  • Android 2.3 Gingerbread est disponible pour les développeurs, beaucoup d'améliorations dont un nouveau Garbage Collector

    Comme vous pouvez le constater sur le site Developpeurs d'Android, Android 2.3 Gingerbread est sorti. Au menu, un nouveau Garbage Collector, des améliorations pour l'accès aux fonctionnalités comme OpenGL ES ou les senseurs depuis un programme natif (en C), support des formats VP8, WebM, AAC et AMR, des nouveaux effets audio, la gestion d'une caméra pour la vidéo-conférence, support de SIP/VOIP, support de Near Field Communication

    Read the article

  • How do I debug a crash when I run my garbage-collected app in Rosetta?

    - by Rob Keniger
    I have a Universal app which is targeting 10.5 and which uses garbage collection. I am building for ppc, i386 and x86_64. I don't have access to a physical PowerPC machine so I am trying to use Rosetta to confirm that the PowerPC portion of the app works correctly. However, as soon as the app is launched in Rosetta it immediately crashes with the following crash log: Process: FooApp [91567] Path: /Users/rob/Development/src/FooApp/build/Release 64-bit/FooApp.app/Contents/MacOS/FooApp Identifier: com.companyX.FooApp Version: 0.9 (build d540e05) (2) Code Type: PPC (Translated) Parent Process: launchd [708] Date/Time: 2010-04-09 18:32:23.962 +1000 OS Version: Mac OS X 10.6.3 (10D573) Report Version: 6 Exception Type: EXC_CRASH (SIGTRAP) Exception Codes: 0x0000000000000000, 0x0000000000000000 Crashed Thread: 5 ...snip non-relevant threads... Thread 5 Crashed: 0 libSystem.B.dylib 0x8023656a __pthread_kill + 10 1 libSystem.B.dylib 0x80235e17 pthread_kill + 95 2 com.companyX.FooApp 0xb80bfb30 0xb8000000 + 785200 3 com.companyX.FooApp 0xb80c0037 0xb8000000 + 786487 4 com.companyX.FooApp 0xb80dd8e8 0xb8000000 + 907496 5 com.companyX.FooApp 0xb8145397 spin_lock_wrapper + 1791 6 com.companyX.FooApp 0xb801ceb7 0xb8000000 + 118455 I have used the Apple docs on debugging translated apps and the information on this page to attach gdb to the app when it's running in Rosetta. The app immediately breaks into the debugger upon launch: Program received signal SIGTRAP, Trace/breakpoint trap. [Switching to thread 15107] 0x9151fdd4 in auto_fatal () (gdb) bt #0 0x9151fdd4 in auto_fatal () #1 0x91536d84 in Auto::Thread::get_register_state () #2 0x915372f8 in Auto::Thread::scan_other_thread () #3 0x91529be4 in Auto::Zone::scan_registered_threads () #4 0x91539114 in Auto::MemoryScanner::scan_thread_ranges () #5 0x9153b000 in Auto::MemoryScanner::scan () #6 0x9153049c in Auto::Zone::collect () #7 0x915198f4 in auto_collect_internal () #8 0x9151a094 in auto_collection_work () #9 0x96687434 in _dispatch_call_block_and_release () #10 0x9668912c in _dispatch_queue_drain () #11 0x96689350 in _dispatch_queue_invoke () #12 0x966895c0 in _dispatch_worker_thread2 () #13 0x966896fc in _dispatch_worker_thread () #14 0x965a97e8 in _pthread_body () (gdb) I have no idea where to start with this. It looks like the Garbage Collector is failing very badly. Are garbage-collected PowerPC apps not supported in Rosetta? I can't see any mention of this limitation in the docs if so. Does anyone have any ideas?

    Read the article

  • How can I avoid garbage collection delays in Java games? (Best Practices)

    - by Brian
    I'm performance tuning interactive games in Java for the Android platform. Once in a while there is a hiccup in drawing and interaction for garbage collection. Usually it's less than one tenth of a second, but sometimes it can be as large as 200ms on very slow devices. I am using the ddms profiler (part of the Android SDK) to search out where my memory allocations come from and excise them from my inner drawing and logic loops. The worst offender had been short loops done like, for(GameObject gob : interactiveObjects) gob.onDraw(canvas); where every single time the loop was executed there was an iterator allocated. I'm using arrays (ArrayList) for my objects now. If I ever want trees or hashes in an inner loop I know that I need to be careful or even reimplement them instead of using the Java Collections framework since I can't afford the extra garbage collection. That may come up when I'm looking at priority queues. I also have trouble where I want to display scores and progress using Canvas.drawText. This is bad, canvas.drawText("Your score is: " + Score.points, x, y, paint); because Strings, char arrays and StringBuffers will be allocated all over to make it work. If you have a few text display items and run the frame 60 times a second that begins to add up and will increase your garbage collection hiccups. I think the best choice here is to keep char[] arrays and decode your int or double manually into it and concatenate strings onto the beginning and end. I'd like to hear if there's something cleaner. I know there must be others out there dealing with this. How do you handle it and what are the pitfalls and best practices you've discovered to run interactively on Java or Android? These gc issues are enough to make me miss manual memory management, but not very much.

    Read the article

  • Appropriate collection for variable-depth list?

    - by George R
    If I wanted to have a collection that described the (recursive) contents of a root directory, including directories and files, how would I store them? Or do I need to come up with an object that holds: -Current directory -Parent directory -Files in directory ..and slap them all in one big list and manually work out the relationship at runtime from each entries Parent directory.

    Read the article

  • Resolving TFS_SCHEMA_VERSION Errors In Team Foundation Server 2010 Collection Databases

    - by Jeff Ferguson
    I recently backed up a Team Foundation Server 2010 project collection database and restored it onto another server. All of that went well, until I tried to use the restored database on the new server. As it turns out, the old server was running the Release Candidate of TFS 2010 and the new server is running the RTM version of TFS 2010. I ended up with an error message shown on the new server's Team Web Access site about the project collection's TFS_SCHEMA_VERSION property not containing the appropriate value. As it turns out, TFS_SCHEMA_VERSION is an extended property on the project collection database. I ran the following SQL script against the project collection database restored onto the new server: EXEC [Tfs_DefaultCollection].sys.sp_dropextendedproperty @name=N'TFS_PRODUCT_VERSION' GO EXEC [Tfs_DefaultCollection].sys.sp_addextendedproperty @name=N'TFS_PRODUCT_VERSION', @value=N'10.0.30319.1' GO EXEC [Tfs_DefaultCollection].sys.sp_dropextendedproperty @name=N'TFS_SCHEMA_VERSION' GO EXEC [Tfs_DefaultCollection].sys.sp_addextendedproperty @name=N'TFS_SCHEMA_VERSION', @value=N'Microsoft Team Foundation Server 2010 (RTM)' GO Now, all is well. I can now navigate to http://newserver:8080/tfs/ and see the restored project collection and its contents.

    Read the article

  • What's the most efficient way to load data from a file to a collection on-demand?

    - by Dan
    I'm working on a java project that will allows users to parse multiple files with potentially thousands of lines. The information parsed will be stored in different objects, which then will be added to a collection. Since the GUI won't require to load ALL these objects at once and keep them in memory, I'm looking for an efficient way to load/unload data from files, so that data is only loaded into the collection when a user requests it. I'm just evaluation options right now. I've also thought of the case where, after loading a subset of the data into the collection, and presenting it on the GUI, the best way to reload the previously observed data. Re-run the parser/Populate collection/Populate GUI? or probably find a way to keep the collection into memory, or serialize/deserialize the collection itself? I know that loading/unloading subsets of data can get tricky if some sort of data filtering is performed. Let's say that I filter on ID, so my new subset will contain data from two previous analyzed subsets. This would be no problem is I keep a master copy of the whole data in memory. I've read that google-collections are good and efficient when handling big amounts of data, and offer methods that simplify lots of things so this might offer an alternative to allow me to keep the collection in memory. This is just general talking. The question on what collection to use is a separate and complex thing. Do you know what's the general recommendation on this type of task? I'd like to hear what you've done with similar scenarios. I can provide more specifics if needed.

    Read the article

  • How to eager fetch a child collection while joining child collection entities to an association

    - by ShaneC
    Assuming the following fictional layout Dealership has many Cars has a Manufacturer I want to write a query that says get me a Dealership with a Name of X and also get the Cars collection but use a join against the manufacturer when you do so. I think this would require usage of ICriteria. I'm thinking something like this.. var dealershipQuery = Session.CreateCriteria< Dealership>("d") .Add(Restrictions.InsenstiveLike("d.Name", "Foo")) .CreateAlias("d.Cars", "c") .SetFetchMode("d.Cars", FetchMode.Select) .SetFetchMode("c.Manufacturer", FetchMode.Join) .UniqueResult< Dealership>(); But the resulting query looks nothing like I would have expected. I'm starting to think a DetachedCriteria may be required somewhere but I'm not sure. Thoughts?

    Read the article

  • Serialize a generic collection specifying element names for items in the collection

    - by mdresser
    I have a simple class derived from a generic list of string as follows: [Serializable] [System.Xml.Serialization.XmlRoot("TestItems")] public class TemplateRoleCollection : List<string> { } when I serialize this, I get the following XML: <TestItems> <string>cat</string> <string>dog</string> <string>wolf</string> </TestItems> Is there any way to override the xml element name which is used for serializing items in the collection? I would like the following xml to be produced: <TestItems> <TestItem>cat</TestItem> <TestItem>dog</TestItem> <TestItem>wolf</TestItem> </TestItems>

    Read the article

  • Declaring and creating an object then adding to collection VS Adding object to collection using new

    - by ZeeMan
    Ok so the title may have been confusing so i have posted 2 code snippets to illustrate what i mean. NOTE: allUsers is just a collection. RegularUser regUser = new RegularUser(userName, password, name, emailAddress); allUsers.Add(regUser); VS allUsers.Add(new RegularUser(userName, password, name, emailAddress)); Which snippet A or B is better and why? What are the advantages or disadvantages? The example i wrote was C# but does the language (C#, Java etc) make a difference?

    Read the article

  • Sort collection within collection using Linq

    - by user327066
    Hi, I have a one-to-many Linq query and I would like to sort on a property within the "many" collection. For example in the pseudo-code below, I am returned a List from the Linq query but I would like to sort / order the Products property based on the SequenceNumber property of the Product class. How can I do this? Any information is appreciated. Thanks. class Order { int OrderId; List<Product> Products; } class Product { string name; int SequenceNumber; }

    Read the article

  • C#, get all collection properties from an object

    - by Eatdoku
    Hi, I have a class with 3 List collections like the following. I am trying to have a logic which will iterate through the object's "collection" properties and do some operation using the data stored in those collections. I am just wondering if there is an easy way of doing it using foreach. thanks public class SampleChartData { public List<Point> Series1 { get; set; } public List<Point> Series2 { get; set; } public List<Point> Series3 { get; set; } public SampleChartData() { Series1 = new List<Point>(); Series2 = new List<Point>(); Series3 = new List<Point>(); } }

    Read the article

  • JavaScript: How can I determine what objects are being collected by the garbage collector?

    - by shino
    I have significant garbage collection pauses. I'd like to pinpoint the objects most responsible for this collection before I try to fix the problem. I've looked at the heap snapshot on Chrome, but (correct me if I am wrong) I cannot seem to find any indicator of what is being collected, only what is taking up the most memory. Is there a way to answer this empirically, or am I limited to educated guesses?

    Read the article

  • How to design a RESTful collection resource?

    - by Suresh Kumar
    I am trying to design a "collection of items" resource. I need to support the following operations: Create the collection Remove the collection Add a single item to the collection Add multiple items to the collection Remove a single item from the collection Remove multiple items from the collection This is as far as I have gone: Create collection: ==> POST /service Host: www.myserver.com Content-Type: application/xml <collection name="items"> <item href="item1"/> <item href="item2"/> <item href="item3"/> </collection> <== 201 Created Location: http://myserver.com/service/items Content-Type: application/xml ... Remove collection: ==> DELETE /service/items <== 200 OK Removing a single item from the collection: ==> DELETE /service/items/item1 <== 200 OK However, I am finding supporting the other operations a bit tricky i.e. what methods can I use to: Add single or multiple items to the collection. (PUT doesn't seem to be right here as per HTTP 1.1 RFC Remove multiple items from the collection in one transaction. (DELETE doesn't seem to right here either)

    Read the article

  • Will the following code be Garbage Collected before the class "dies"?

    - by devoured elysium
    Let's say we have the following code in a class: //class code TextBox t = new TextBox(); ListBox l = new ListBox(); We have then two possible situations: In the first, we declare qem1 as a class variable(or attribute, as they call it in the Java World): //class variable QuickEntryMediator qem1 = new QuickEntryMediator(t,l); In the second, we declare it inside a method: //method variable QuickEntryMediator qem2 = new QuickEntryMediator(t,l); So, I'd say qem1 would never be Garbage Collected before the class goes out of scope while in the qem2 might be Garbage Collected at any time after the method in which it resides dies. Is this true? I am looking for answers for both C#(.net) and Java, as am I am not sure both GC's work in the same fashion! Thanks

    Read the article

  • 302 Redirect causes garbage at end of Wordpress link in Facebook

    - by Joao
    When I try to link my Wordpress blog to Facebook, the url doesn't resolve properly. There's garbage appended at the end and Facebook is not able to retrieve information from the site. Happens in every page, post or main entry. Here's what happens: http://clarissarezende.com.br/ shows up in Facebook as http://clarissarezende.com.br/UPLcS/ (when copy/paste the link) and no information about the site shows up in FB. I'm using Wordpress 3.3.1 with ProPhoto 4. Recently I moved the DNS entry on my ISP. The blog is hosted at clarissarezende.com.br/public_html/blog2 and before the DNS would point to public_html and then I changed it to public_html/blog2. Note that I did not move any Wordpress files. Made the (I think) necessary changes all over Facebook, but still no dice... Any ideas on what can be happening?

    Read the article

  • Why is the destructor called when the CPython garbage collector is disabled?

    - by Frederik
    I'm trying to understand the internals of the CPython garbage collector, specifically when the destructor is called. So far, the behavior is intuitive, but the following case trips me up: Disable the GC. Create an object, then remove a reference to it. The object is destroyed and the __del__ method is called. I thought this would only happen if the garbage collector was enabled. Can someone explain why this happens? Is there a way to defer calling the destructor? import gc import unittest _destroyed = False class MyClass(object): def __del__(self): global _destroyed _destroyed = True class GarbageCollectionTest(unittest.TestCase): def testExplicitGarbageCollection(self): gc.disable() ref = MyClass() ref = None # The next test fails. # The object is automatically destroyed even with the collector turned off. self.assertFalse(_destroyed) gc.collect() self.assertTrue(_destroyed) if __name__=='__main__': unittest.main() Disclaimer: this code is not meant for production -- I've already noted that this is very implementation-specific and does not work on Jython.

    Read the article

  • Are there any Python reference counting/garbage collection gotchas when dealing with C code?

    - by Jason Baker
    Just for the sheer heck of it, I've decided to create a Scheme binding to libpython so you can embed Python in Scheme programs. I'm already able to call into Python's C API, but I haven't really thought about memory management. The way mzscheme's FFI works is that I can call a function, and if that function returns a pointer to a PyObject, then I can have it automatically increment the reference count. Then, I can register a finalizer that will decrement the reference count when the Scheme object gets garbage collected. I've looked at the documentation for reference counting, and don't see any problems with this at first glance (although it may be sub-optimal in some cases). Are there any gotchas I'm missing? Also, I'm having trouble making heads or tails of the cyclic garbage collector documentation. What things will I need to bear in mind here? In particular, how do I make Python aware that I have a reference to something so it doesn't collect it while I'm still using it?

    Read the article

  • Which type of data can be garbage collected when app is in background?

    - by Neoh
    Let's say I start from activity A - activity B. While in activity B I press home to exit. After a long time, gc may be called because other apps take higher priority. My question is, which of the following type of data will be garbage collected (I'm pretty sure static fields can be garbage collected any time but I'm not sure about these): i) fields that are declared final or static final ii) intent and its data that I passed from activity A to activity B iii) onSavedInstanceState when orientation is changed during the app running I ask this because I want to ensure that my app won't crash when I restore activity B from background after a long period.

    Read the article

  • Exception during iteration on collection and remove items from that collection

    - by Muhammad Kashif Nadeem
    I remove item from ArrayList in foreach loop and get follwing exception. Collection was modified; enumeration operation may not execute. How can I remove items in foreach Following is my code: /* * Need to remove all items from 'attachementsFielPath' which does not exist in names array. */ try { string attachmentFileNames = txtAttachment.Text.Trim(); // Textbox having file names. string[] names = attachmentFileNames.Split(new char[] { ';' }); int index = 0; // attachmentsFilePath is ArrayList holding full path of fiels user selected at any time. foreach (var fullFilePath in attachmentsFilePath) { bool isNeedToRemove = true; // Extract filename from full path. string fileName = fullFilePath.ToString().Substring(fullFilePath.ToString().LastIndexOf('\\') + 1); for (int i = 0; i < names.Length; i++) { // If filename found in array then no need to check remaining items. if (fileName.Equals(names[i].Trim())) { isNeedToRemove = false; break; } } // If file not found in names array, remove it. if (isNeedToRemove) { attachmentsFilePath.RemoveAt(index); isNeedToRemove = true; } index++; } } catch (Exception ex) { throw ex; }

    Read the article

  • How can I write a unit test to determine whether an object can be garbage collected?

    - by driis
    In relation to my previous question, I need to check whether a component that will be instantiated by Castle Windsor, can be garbage collected after my code has finished using it. I have tried the suggestion in the answers from the previous question, but it does not seem to work as expected, at least for my code. So I would like to write a unit test that tests whether a specific object instance can be garbage collected after some of my code has run. Is that possible to do in a reliable way ? EDIT I currently have the following test based on Paul Stovell's answer, which succeeds: [TestMethod] public void ReleaseTest() { WindsorContainer container = new WindsorContainer(); container.Kernel.ReleasePolicy = new NoTrackingReleasePolicy(); container.AddComponentWithLifestyle<ReleaseTester>(LifestyleType.Transient); Assert.AreEqual(0, ReleaseTester.refCount); var weakRef = new WeakReference(container.Resolve<ReleaseTester>()); Assert.AreEqual(1, ReleaseTester.refCount); GC.Collect(); GC.WaitForPendingFinalizers(); Assert.AreEqual(0, ReleaseTester.refCount, "Component not released"); } private class ReleaseTester { public static int refCount = 0; public ReleaseTester() { refCount++; } ~ReleaseTester() { refCount--; } } Am I right assuming that, based on the test above, I can conclude that Windsor will not leak memory when using the NoTrackingReleasePolicy ?

    Read the article

  • How does the Garbage Collector decide when to kill objects held by WeakReferences?

    - by Kennet Belenky
    I have an object, which I believe is held only by a WeakReference. I've traced its reference holders using SOS and SOSEX, and both confirm that this is the case (I'm not an SOS expert, so I could be wrong on this point). The standard explanation of WeakReferences is that the GC ignores them when doing its sweeps. Nonetheless, my object survives an invocation to GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced). Is it possible for an object that is only referenced with a WeakReference to survive that collection? Is there an even more thorough collection that I can force? Or, should I re-visit my belief that the only references to the object are weak?

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >