Search Results

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

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

  • Synchronizing a collection of wrapped objects with a collection of unwrapped objects

    - by Kenneth Cochran
    I have two classes: Employee and EmployeeGridViewAdapter. Employee is composed of several complex types. EmployeeGridViewAdapter wraps a single Employee and exposes its members as a flattened set of system types so a DataGridView can handle displaying, editing, etc. I'm using VS's builtin support for turning a POCO into a data source, which I then attach to a BindingSource object. When I attach the DataGridView to the BindingSource it creates the expected columns and at runtime I can perform the expected CRUD operations. All is good so far. The problem is the collection of adapters and the collection of employees aren't being synchronized. So all the employees I create an runtime never get persisted. Here's a snippet of the code that generates the collection of EmployeeGridViewAdapter's: var employeeCollection = new List<EmployeeGridViewAdapter>(); foreach (var employee in this.employees) { employeeCollection.Add(new EmployeeGridViewAdapter(employee)); } this.view.Employees = employeeCollection; Pretty straight forward but I can't figure out how to synchronize changes back to the original collection. I imagine edits are already handled because both collections reference the same objects but creating new employees and deleting employees aren't happening so I can't be sure.

    Read the article

  • Is it better to use List or Collection?

    - by Vivin Paliath
    I have an object that stores some data in a list. The implementation could change later, and I don't want to expose the internal implementation to the end user. However, the user must have the ability to modify and access this collection of data. Currently I have something like this: public List<SomeDataType> getData() { return this.data; } public void setData(List<SomeDataType> data) { this.data = data; } Does this mean that I have allowed the internal implementation details to leak out? Should I be doing this instead? public Collection<SomeDataType> getData() { return this.data; } public void setData(Collection<SomeDataType> data) { this.data = new ArrayList<SomeDataType>(data); }

    Read the article

  • what is the pattern for modifying a collection in C#

    - by macias
    What is the pattern (best practice) for such problem -- modifying elements (values) in collection? Conditions: size of the collection is not changed (no element is deleted or added) modification is in-place In C++ it was easy and nice, I just iterated trough a collection and changed the elements. But in C# iterating (using enumerator) is read-only operation (speaking in terms of C++, only const_iterator is available). So, how to do this in C#? Example: having sequence of "1,2,3,4" modification is changing it to "1, 2, 8, 9" but not "1, 2, 3" or "1, 2, 3, 4, 5".

    Read the article

  • Get Item from Collection by unique ID

    - by David Murdoch
    I have a collection of Contacts that inherits from CollectionBase: public class ContactCollection : CollectionBase{ //... } each contact in the collection has a unique ID: public class Contact{ public int ContactID{ get; private set; } //... } I think what I would like to do is something like the following: // get the contact by their unique [Contact]ID Contact myPerson = Contact.GetContactById(15); // get all contacts for the customer ContactCollection contacts = customer.GetContacts(); // replaces the contact in the collection with the // myPerson contact with the same ContactID. contacts.ReplaceAt(myPerson); // saves the changes to the contacts and the customer // customer.Save(); There is probably a better way...if so, please suggest it.

    Read the article

  • WPF/MVVM: Delegating a domain Model collection to a ViewModel

    - by msfanboy
    A domain model collection (normally a List or IEnumerable) is delegated to a ViewModel. Thats means my CustomerViewModel has a order collection of type List or IEnumerable. No change in the list is recognized by the bound control. But with ObservableCollection it is. This is a problem in the MVVM design pattern. How do you cope with it?

    Read the article

  • C#: What is the best collection class to store very similar string items for efficient serialization

    - by Gregor
    Hi, I would like to store a list of entityIDs of outlook emails to a file. The entityIDs are strings like: "000000005F776F08B736B442BCF7B6A7060B509A64002000" "000000005F776F08B736B442BCF7B6A7060B509A84002000" "000000005F776F08B736B442BCF7B6A7060B509AA4002000" as you can notice, the strings are very similar. I would like to save these strings in a collection class that would be stored as efficiently as possible when I serialize it to a file. Do you know of any collection class that could be used for this? Thank you in advance for any information... Gregor

    Read the article

  • Want to add new properies in ListItem Collection

    - by Kamlesh
    I am working on to create a custom control inherited by CheckboxList control. We can add items from ListItem collection editior at the design time. In this ListItem Collection editor there are 4 properties 1) Enabled 2) Selected3) Text4) valueI really need to add some new properties such as "ImageURL" and "IsClear". Is there any ideas/methods or magic to add these properties.

    Read the article

  • Is there a way to launch an aggressive and complete garbage collection in Java?

    - by Gnoupi
    For memory optimization reasons, I'm launching myself the garbage collector during profiling, to check if objects are correctly cleaned after disposing of them. The call to garbage collector is not enough, though, and it seems that there is no guarantee of what it will clean. Is there a way to call it, to be sure it will recover as much as it can, in profiling conditions (this would have no point in production, of course)? Or is "calling it several times" the only way to be "almost sure"? Or did I simply misunderstand something about the Garbage Collector?

    Read the article

  • Information regarding Collection 6233 - Implementing and Maintaining Business Intelligence in Micros

    - by Testas
    At the London SQL Server User Group I was asked a number of questions regarding the release of Collection 6233 - Implementing and Maintaining Business Intelligence in Microsoft® SQL Server® 2008: Integration Services, Reporting Services and Analysis Services, which has been authored by myself. Particularly regarding the SSIS component of the collection. Elearning is an interactive training experience that enables you to learn at your own pace. With a variety of learning tools including demonstrations, animations as well as written materials and the addition of labs that enables you to reinforce your learning. Microsoft Elearning can provide a valuable learning tool when you may not have the time to take out of the office to attend a courseThis 24-hour collection provides you with the skills and knowledge required to implement and maintain business intelligence solutions on SQL Server 2008 and also helps students to prepare for Exam 70-448 and you can buy each part individually see: http://www.microsoft.com/learning/elearning/course/6233.mspx   However, you will create a simple data warehouse in this collection and use SSIS to create packages to populate the data warehouse with data, exploring key concepts and tools to faciliatate this. This was a decision thart I took when writing this course based on feedback from hundreds of students who attended Microsoft Official Courses on SSIS. They wanted a course that allowed them to use SSIS to work with a data warehouse. This collection will certainly enable you to explore the options available in SSIS to meet this requirement while at the same time meeting the certification requirements I hope this answers the questions regarding this collection and hope you enjoy this collection   Chris  

    Read the article

  • Binding collection indexes to a WPF DataGrid at runtime

    - by bearda
    After trying to develop our own control to display a table of data we stumbled on the WPF toolkit DataGrid and thought we were saved. A couple hours later I'm scratching my head trying to figure out if it can do what we really want it to do. The DataGrid seems to be based on displaying various properties of a single object, where I think I need something that can display a collection's items, I want to display a table of strings with a variable number of rows and a variable number of columns. Each row represents the state of a number of inputs at a given time. The number of samples may change, and the number of inputs may change at runtime. As a result, I can't create a custom object that represents a row with a property for each input. This makes the DataGrid binding more complicated, since I can't bind to a fixed property for each column. I thought I found a workaround for this by binding to ".[" + channelIndex + ]" but it hasn't worked out quite the way I wanted. Right now I have a collection of a collection of strings that represents the two-dimensional array of strings. I'm using ObservableCollection so string change event notifications work, but I can use any collection type needed. It looked like everything was working great until I realized that every row was showing the same line of data. Binding in C# is not my strong suit, so I'm kind of lost on what's going wrong. Is what I'm trying to do overall even possible with the WPF Toolkit DataGrid? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Microsoft.Windows.Controls; using System.ComponentModel; using System.Collections; using System.Collections.ObjectModel; namespace WRE.NGDAS.UILayer { /// <summary> /// Interaction logic for DataTableControl.xaml /// </summary> public partial class DataTableControl : UserControl { #region Constants private const int lineHeight = 25; #endregion #region Type Definitions private class TableChannelInfo { internal string ChannelName = string.Empty; internal int Column = 0; public override string ToString() { return ChannelName; } } internal class NotifyString : INotifyPropertyChanged { private string text = String.Empty; public event PropertyChangedEventHandler PropertyChanged; public string Text { get { return text; } set { text = value; NotifyPropertyChanged( "Text" ); } } public NotifyString(string newText) { text = newText; } protected void NotifyPropertyChanged( string propertyChanged ) { if ( PropertyChanged != null ) { PropertyChanged(this, new PropertyChangedEventArgs(propertyChanged)); } } } #endregion #region Private Data Members string[] channels = null; int numberFixed = 0; int numberOfRows = 0; ObservableCollection<ObservableCollection<NotifyString>> tableText = null; #endregion public DataTableControl( List<string> channelNames, List<string> nameToolTips, int numberFixedColumns, int numberRows ) { InitializeComponent(); numberFixed = numberFixedColumns; numberOfRows = numberRows; tableText = new ObservableCollection<ObservableCollection<NotifyString>>(); dataGrid.ItemsSource = tableText; channels = new string[channelNames.Count]; for (int channelIndex = 0; channelIndex < channelNames.Count; channelIndex++) { channels[channelIndex] = channelNames[channelIndex]; tableText.Add(new ObservableCollection<NotifyString>()); for (int i = 0; i < numberOfRows; i++) { tableText[channelIndex].Add( new NotifyString(String.Empty) ); } Binding textBinding = new Binding( ".[" + channelIndex + "]" ); textBinding.Mode = BindingMode.OneWay; textBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; textBinding.Source = tableText[channelIndex]; DataGridTextColumn newColumn = new DataGridTextColumn(); newColumn.Header = channelNames[channelIndex]; newColumn.DisplayIndex = channelIndex; newColumn.Binding = textBinding; if ( channelIndex < numberFixed ) { newColumn.CanUserReorder = false; } dataGrid.Columns.Add(newColumn); } //Height = lineHeight + numberOfRows * lineHeight; } internal void UpdateChannelRow( int rowNumber, List<string> channelValues, DisplayColors color ) { if ( rowNumber < numberOfRows ) { for (int column = 0; column < channelValues.Count; column++) { if ( column < channels.GetLength(0) ) { tableText[column][rowNumber].Text = channelValues[column]; } } } } } }

    Read the article

  • c# inheriting generic collection and serialization...

    - by Stecy
    Hi, The setup: class Item { private int _value; public Item() { _value = 0; } public int Value { get { return _value; } set { _value = value; } } } class ItemCollection : Collection<Item> { private string _name; public ItemCollection() { _name = string.Empty; } public string Name { get {return _name;} set {_name = value;} } } Now, trying to serialize using the following code fragment: ItemCollection items = new ItemCollection(); ... XmlSerializer serializer = new XmlSerializer(typeof(ItemCollection)); using (FileStream f = File.Create(fileName)) serializer.Serialize(f, items); Upon looking at the resulting XML I see that the ItemCollection.Name value is not there! I think what may be happening is that the serializer sees the ItemCollection type as a simple Collection thus ignoring any other added properties... Is there anyone having encountered such a problem and found a solution? Regards, Stécy

    Read the article

  • Java Spotlight Episode 86: Tony Printezis on Garbage Collection First

    - by Roger Brinkley
    Interview with Tony Printezis on Garbage Collection First (GC1). Joining us this week on the Java All Star Developer Panel is Arun Gupta, Java EE Guy. Right-click or Control-click to download this MP3 file. You can also subscribe to the Java Spotlight Podcast Feed to get the latest podcast automatically. If you use iTunes you can open iTunes and subscribe with this link:  Java Spotlight Podcast in iTunes. Show Notes News JSR 358: A major revison of the Java Community Process - JCP 3.Next JAX-RS 2.0 Early Draft- Third Edition Events June 11-14, Cloud Computing Expo, New York City June 12, Boulder JUG June 13, Denver JUG June 13, Eclipse Juno DemoCamp, Redwoood Shore June 13, JUG Münster June 14, Java Klassentreffen, Vienna, Austria June 18-20, QCon, New York City June 19, CJUG, Chicago June 20, 1871, Chicago June 26-28, Jazoon, Zurich, Switzerland Jun 27, Houston JUG ?? July 5, Java Forum, Stuttgart, Germany Jul 13-14, IndicThreads, Delhi July 30-August 1, JVM Language Summit, Santa Clara Feature InterviewTony Printezis is a Principal Member of Technical Staff at Oracle, based in Burlington, MA. He has been contributing to the Java HotSpot Virtual Machine since 2006. He spends most of his time working on dynamic memory management for the Java platform, concentrating on performance, scalability, responsiveness, parallelism, and visualization of garbage collectors. He obtained a Ph.D. in 2000 and a BSc (Hons) in 1995, both from the University of Glasgow in Scotland. In addition, he is a JavaOne Rock Star, a title awarded for his highly rated JavaOne session on GC. Mail Bag What’s Cool JavaOne content selection is complete. Notifications done.

    Read the article

  • "Collection Wrapper" pattern - is this common?

    - by Prog
    A different question of mine had to do with encapsulating member data structures inside classes. In order to understand this question better please read that question and look at the approach discussed. One of the guys who answered that question said that the approach is good, but if I understood him correctly - he said that there should be a class existing just for the purpose of wrapping the collection, instead of an ordinary class offering a number of public methods just to access the member collection. For example, instead of this: class SomeClass{ // downright exposing the concrete collection. Things[] someCollection; // other stuff omitted Thing[] getCollection(){return someCollection;} } Or this: class SomeClass{ // encapsulating the collection, but inflating the class' public interface. Thing[] someCollection; // class functionality omitted. public Thing getThing(int index){ return someCollection[index]; } public int getSize(){ return someCollection.length; } public void setThing(int index, Thing thing){ someCollection[index] = thing; } public void removeThing(int index){ someCollection[index] = null; } } We'll have this: // encapsulating the collection - in a different class, dedicated to this. class SomeClass{ CollectionWrapper someCollection; CollectionWrapper getCollection(){return someCollection;} } class CollectionWrapper{ Thing[] someCollection; public Thing getThing(int index){ return someCollection[index]; } public int getSize(){ return someCollection.length; } public void setThing(int index, Thing thing){ someCollection[index] = thing; } public void removeThing(int index){ someCollection[index] = null; } } This way, the inner data structure in SomeClass can change without affecting client code, and without forcing SomeClass to offer a lot of public methods just to access the inner collection. CollectionWrapper does this instead. E.g. if the collection changes from an array to a List, the internal implementation of CollectionWrapper changes, but client code stays the same. Also, the CollectionWrapper can hide certain things from the client code - from example, it can disallow mutation to the collection by not having the methods setThing and removeThing. This approach to decoupling client code from the concrete data structure seems IMHO pretty good. Is this approach common? What are it's downfalls? Is this used in practice?

    Read the article

  • Why an object declared in method is subject to garbage collection before the method returns?

    - by SiLent SoNG
    Consider an object declared in a method: public void foo() { final Object obj = new Object(); // A long run job that consumes tons of memory and // triggers garbage collection } Will obj be subject to garbage collection before foo() returns? UPDATE: Previously I thought obj is not subject to garbage collection until foo() returns. However, today I find myself wrong. I have spend several hours in fixing a bug and finally found the problem is caused by obj garbage collected! Can anyone explain why this happens? And if I want obj to be pinned how to achieve it? Here is the code that has problem. public class Program { public static void main(String[] args) throws Exception { String connectionString = "jdbc:mysql://<whatever>"; // I find wrap is gc-ed somewhere SqlConnection wrap = new SqlConnection(connectionString); Connection con = wrap.currentConnection(); Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); stmt.setFetchSize(Integer.MIN_VALUE); ResultSet rs = stmt.executeQuery("select instance_id, doc_id from crawler_archive.documents"); while (rs.next()) { int instanceID = rs.getInt(1); int docID = rs.getInt(2); if (docID % 1000 == 0) { System.out.println(docID); } } rs.close(); //wrap.close(); } } After running the Java program, it will print the following message before it crashes: 161000 161000 ******************************** Finalizer CALLED!! ******************************** ******************************** Close CALLED!! ******************************** 162000 Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: And here is the code of class SqlConnection: class SqlConnection { private final String connectionString; private Connection connection; public SqlConnection(String connectionString) { this.connectionString = connectionString; } public synchronized Connection currentConnection() throws SQLException { if (this.connection == null || this.connection.isClosed()) { this.closeConnection(); this.connection = DriverManager.getConnection(connectionString); } return this.connection; } protected void finalize() throws Throwable { try { System.out.println("********************************"); System.out.println("Finalizer CALLED!!"); System.out.println("********************************"); this.close(); } finally { super.finalize(); } } public void close() { System.out.println("********************************"); System.out.println("Close CALLED!!"); System.out.println("********************************"); this.closeConnection(); } protected void closeConnection() { if (this.connection != null) { try { connection.close(); } catch (Throwable e) { } finally { this.connection = null; } } } }

    Read the article

  • Know of any Java garbage collection log analysis tools?

    - by braveterry
    I'm looking for a tool or a script that will take the console log from my web app, parse out the garbage collection information and display it in a meaningful way. I'm starting up on a Sun Java 1.4.2 JVM with the following flags: -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails The log output looks like this: 54.736: [Full GC 54.737: [Tenured: 172798K->18092K(174784K), 2.3792658 secs] 257598K->18092K(259584K), [Perm : 20476K->20476K(20480K)], 2.4715398 secs] Making sense of a few hundred of these kinds of log entries would be much easier if I had a tool that would visually graph garbage collection trends.

    Read the article

  • .NET object creation and generations

    - by nimoraca
    Is there a way to tell the .NET to allocate a new object in generation 2 heap. I have a problem where I need to allocate approximately 200 MB of objects, do something with them, and throw them away. What happens here is that all the data gets copied two times (from gen0 to gen1 and then from gen1 to gen2).

    Read the article

  • Java GC: top object classes promoted (by size)?

    - by Java Geek
    Hello! Please let me know what is the best way to determine composition of young generation memory promoted to old generation, after each young GC event? Ideally I would like to know class names which are responsible say, for 80% of heap in each "young gen - old gen" promotion chunk; Example: I have 600M young gen, each tenure promotes 6M; I want to know which objects compose this 6M. Thank you.

    Read the article

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