kev.Blog()

April 26, 2012

Never Rely on the FCL to Dispose

Filed under: Performance — Tags: , , — kevinhick @ 2:32 pm

I was changing some old code when I came across this: 

XslCompiledTransform xslt = new XslCompiledTransform();

xslt.Load(new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(BuildManifestTransform)));

Hmmm’ I said to myself ‘Readers and Streams are usually disposable, but this XmlTextReader and the UnmanagedMemoryStream from GetManifestResourceStream aren’t being disposed.  I wonder if they’re being disposed inside the Load method…’.

I didn’t think they were, but to double check I fired up the SciTech memory profiler we’ve purchased for finding leaks:

image

It reported that the code wasn’t disposing either the XmlTextReader (see ‘Delta undisposed instances: 1’ above) or the UnmanagedMemoryStream, so the underlying resources were not going to be cleaned up until the finalizer thread got around to it.  This goes to show that you can’t rely on the Framework Class Library methods that accept disposable classes to dispose them.

I reorganised the code to ensure that the disposable objects were going to be disposed, like so:

XslCompiledTransform xslt = new XslCompiledTransform();
Assembly thisAssembly = Assembly.GetExecutingAssembly();

using (Stream manifestResourceStream = thisAssembly.GetManifestResourceStream(BuildManifestTransform))
{
        using (XmlTextReader reader = new XmlTextReader(manifestResourceStream))
        {
                xslt.Load(reader);
         }
}

I re-ran the memory profiler and it reported ‘Delta undisposed instances: 0’ for both classes.

image

If you want a good job doing…

Advertisements

June 13, 2011

Symstore Error on Delete

Filed under: Debugging — Tags: — kevinhick @ 3:54 pm

Our symbol server store needs clearing up, so I tried deleting those symbols where the build was no longer present in Team System.

On our Development server, the del transaction worked fine, on the pre-production server, I got this error:

SYMSTORE ERROR: Class: Server. Desc: Couldn’t get transaction id from \\my_symbol_server\my_symbol_share

I checked the folder permissions, file permissions and symbol transaction files to no avail.

Google was no help, so I’m posting the very simple answer.

On the pre-production server, the share permissions didn’t allow the account I was running with to edit.

I switched the command to use the local drive to make it work, but changing the permissions on the share would also have worked.

Also, if you’ve correctly set permissions on the share, but have forgotten the file system permissions, you will get this error: ‘refs.ptr doesn’t contain any valid transaction history’.

March 12, 2010

Red X on my tfpt Subteam Members node

Filed under: TFS — kevinhick @ 9:37 am

A while back I told you about the Red X on my tfpt Team Members node in Team Explorer.  This time the red x is on a SubTeam node.

To find out what was going on I hunted through my Output window and found this message in the General section:

"Adding the {Group Name} group with {Group Members Count} members to the Team Members hierarchy would bring the total users to {Total Members Count} and would make it too large to display."

I tracked down the hard limit by using Reflector, it’s 250.

Of course, should you wish to work with the group that has fallen foul of this limit you can work around it by temporarily changing your Team Members Personal Settings, i.e. change the ‘Group defining team members’ to the SubTeam you want to work with.

June 30, 2009

Synchronising Comments Between TFS and QC

Filed under: Juvander — kevinhick @ 12:05 pm

There’s been a couple of questions on the Juvander forums about how to sync comments from the TFS History fieldinto Quality Center.

Unfortunately the TFS Bug Item Synchroniser doesn’t have this feature yet, but there is a way to do it.

Step 1

Create a new ‘QC Comments’ html field in your TFS work item. In my solution this is a read only field on the work item form and is updated from the Comments in the Work Item History field only.

Step 2

Configure the Synchroniser to sync the QC Comments field with the new custom TFS field.

I’ve checked the ‘HTML Formatted Field’ option from QC to TFS but not vice versa and configured an invalid character filter value map for the QC to TFS sync (I also use this on Title and Description)

<ValueMap Name="FilterInvalidChars">
<Value MatchTypeValue="RegularExpressionMatch" ReplaceString=" " PatternString="[^\t\r\n\u0020-\uFFFD]" MatchPatternString="[^\t\r\n\u0020-\uFFFD]" />
</ValueMap>        

Step 3

Create a Web Service that subscribes to the WorkItemChangedEvent from TFS

The History field (which if changed will be in the TextFields array) will be populated with any additions, so test the work item change event for an addition and append the comments to the custom ‘QC Comments’ field, marking with ChangedBy for more info. In my solution I also remove the changed field xml by removing everything between ‘<div‘ and ‘div>‘ and exclude ‘Associated with Changeset’ comments.

Now when comments are made in TFS, the web service updates the ‘QC Comments’ field and the Synchroniser updates QC from that. When QC comments are updated the Synchroniser just does a straight update to the ‘QC Comments’ field.

May 26, 2009

‘TF14086: Cannot merge’ Workaround

Filed under: TFS — kevinhick @ 1:03 pm

Whilst doing a merge from DEV to MAIN I was presented with the following error:

TF14086: Cannot merge $/Project/DEV/System/Current/Folder/File.cs to
$/Project/MAIN/System/RenamedFolder/File.cs because there is an unrelated item at
$/Project/MAIN/System/RenamedFolder/File.cs.

It turned out that the file causing the problem was new (i.e. not in MAIN yet) and the containing folder had been renamed in DEV. This pending change showed up in MAIN like so:

Folder/File

Pending change

$/Project/MAIN/System/RenamedFolder

merge, rename

$/Project/MAIN/System/RenamedFolder/File.cs

merge, branch

The way around this is to undo the pending merge for the new file, check-in the pending change for the rename of the folder, then do another merge for the new file.

March 23, 2009

VSTF Test Tools Adapter Warning:6501 Causes missing Manual Test Results

Filed under: TFS — kevinhick @ 1:51 pm

I started working with Manual Tests recently to support another team that wanted to use them and was getting to grips with them quite nicely when my custom reports stopped updating.  I tried to perform the same queries in Excel and it showed that the test results and outcomes were not finding their way into the warehouse.

I turned to my friend Dan Sloan from Wintellect to help me out as I thought it might be caused by my inexperience with Manual Tests.  He pointed me in the direction of the Event Log on my Team System App Tier and we found the following Warning there:

TF53010: The following error has occurred in a Team Foundation component or extension
Assembly: Microsoft.VisualStudio.QualityTools.WarehouseAdapter
Encountered an exception while inserting test results for test run <GUID>
Attempting to continue processing other test run data. Exception: Microsoft.TeamFoundation.Server.GroupSecuritySubsystemException:
TF50605: There was an error looking up the SID for Hick, Kevin (MyCompany, My Dept)

Figuring it may be a problem with my account we looked it up with the TFSAdmin SID command, but that looked fine.  We then deleted all Test Results from all builds and tried publishing with a different account.  More dates appeared in the reports but the Cumulative Outcomes didn’t have any additions.  We looked in the Event Log again and although I had published the tests under a different account the VSTF Test Tools Adapter Warning still appeared and it was still for my account.

ManualTestOwnerErrorSo I took the GUID noted in the Event Log message and queried the database for related records, which is of course what I should’ve done to start with, then it hit me; I had filled in the properties on my Manual Tests with relevant details e.g. Associated Work Item Ids, Area and Iteration, and had noticed the Owner property.  I had expected there to be a ‘browse button’ that would take me to a list of Valid TFS Users, but there wasn’t one, so I’d figured it needed my Display Name, as appears in a Work Item dialog.  This is of course the wrong thing to do and I should’ve entered Owner as <My Login Id > or <My Domain>\<My Login Id>, although I have since looked up how to set the Owner property in the MSDN and two books and they do not explicitly specify this important piece of information.

Once all the invalid Test Results had been deleted from the builds and the Owner property on the Manual Tests replaced with my login id everything started working as expected.

My thanks to Dan for helping me out on this one!

February 12, 2009

Forbidden Patterns Policy Example

Filed under: TFS — kevinhick @ 9:36 am

I thought I’d post this as I couldn’t find an example of this anywhere.

It’s the regex for disallowing certain binary files in all folders apart from _Dependencies (it also forbids VB and C++ as we’re a C# shop)

(?(((?!\b_Dependencies\b).)*$)^(?=.+\.((asf)|(asp)|(avi)|(bas)|(bat)|(c)|(cab)|(cc)|(cd)|(cda)|(cgi)|(chm)|(cls)|(cmd)|(com)|(cpp)|(dl_)|(dll)|(doc)|(dochtml)|(docm)|(docx)|(docxml)|(dsw)|(ex_)|(exe)|(iso)|(jar)|(java)|(mdb)|(mht)|(mov)|(movie)|(mp3)|(mp4)|(mpp)|(msi)|(obj)|(oc_)|(ocx)|(odc)|(odh)|(odl)|(one)|(pas)|(pdb)|(pdf)|(pps)|(ppsm)|(ppsx)|(ppt)|(pptm)|(pptmhtml)|(pptx)|(profileresults)|(rar)|(tlb)|(trx)|(vb)|(vbe)|(vbproj)|(vcw)|(vdx)|(vsd)|(vss)|(vsw)|(wav)|(wmv)|(xls)|(xlsx)|(xps)|(zip))$)|!.*)

January 14, 2009

Talk to the hand!

Filed under: Debugging — kevinhick @ 11:22 pm

I was called in on a problem with a slow starting application that was affecting some developers and some users, but not all. In the normal case the app would start up in around 5 seconds, whereas the effected users experienced start times of around 30 seconds.

The dev team had engaged the database gurus in case it was related to database access and the domain guys in case it was a profile issue, but to no avail.

As the issue was specific to individuals – even when logging on to other workstations, the likelihood was that it was profile related; but where to start?

My first approach was to use our network monitoring tool. Once the remote agent was installed on the workstation in question this would show all network activity, e.g. SQL Server, MQ or Web Service calls and network file access. This showed no database activity until around 30 seconds into the app start up, but once this had started the app was up within 5 seconds; there was nothing else of interest. This pointed to the problem being something that was happening locally, so I took a trip to see the developer with the problem and found animated cursors, Yuk! After I’d got over the shock of the coloured mouse pointer I fired up SysInternals Process Monitor on the affected workstation.

 

Curiously, there was a 26 second gap in activity followed by a QueryOpen for W:\common\wmbitmap\hand.cur with a result of FAST IO DISALLOWED – interesting! The animated pointer scheme seemed to be doing more than just annoying me J.

I took a look at the W:\ drive and found that it was mapped to a server that had been decommissioned, and from the look of the file access the app was trying to display a hand cursor from that drive. I figured that the pointer scheme must have been changed when that drive was available and somehow, windows had registered the cursors there.

I disconnected the W:\ drive and set the pointer scheme to the default – problem solved; the app now started up in 5 seconds again. I could even put the animated pointer scheme back on, now that the W:\ drive was out of the picture – each to their own I guess!

January 8, 2009

Red X on my tfpt Team Members node

Filed under: TFS — kevinhick @ 4:53 pm

I wanted to create some Sub Teams under Contributors on a new Team Project but I was getting the Red X on my Team Members node even though all my other Team Projects were working fine. I tried changing my personal settings, edited the PersonalSettings.config file, I even discovered the TeamTrackerEnabled and TeamTrackerHidden registry settings.

In one of those ‘I don’t believe the answer could be this simple because Microsoft wouldn’t make that kind of mistake, but I’m going to try it anyway‘ moments, I theorised that the 105 people in my Contributors group was too many for the power tool to cope with, so I started creating my Sub Teams through the Group Security Dialogs.

After I had created my first Sub Team and moved a handful of people in there I hit the refresh on the context menu – ta da, problem solved!

Hmmm, could it be that there is a limit of 100 ungrouped contributors before the power tool fails? In this reporters opinion – Yes!

Notes:

You’ll find the in the PersonalSettings.config file in C:\Users\<User>\Application Data\Microsoft\Team Foundation Server.

The registry settings can be added as strings at HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Power Tools

When set to False, TeamTrackerEnabled disables the node, TeamTrackerHidden disables the settings context menu

January 5, 2009

Error importing work item type definition: The given key was not present in the dictionary

Filed under: TFS — kevinhick @ 9:09 am

In a follow up to my previous post, if you receive this error: "The given key was not present in the dictionary" when you upload the work item type, you may have left a reference to a field that you’ve now removed, in a rule on another field, e.g.

<!– Commenting out this field will result in an error if the rule below is not removed
<FIELD type="String" name="Removed Field" refname="Custom.RemovedField">
   
<HELPTEXT>The Quality Center Defect ID</HELPTEXT>
</FIELD>
–>

<FIELD type="String" name="Field that references the one above" refname="Custom.ReferencingField">
   
<WHENNOT field="Custom.RemovedField" value="Deleted"><!–This refers to a field that no longer exists –>
       
<REQUIRED />
   
</WHENNOT>
</FIELD>

Older Posts »

Blog at WordPress.com.