Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

How TFS stores workspace information

Given the recent problems on CodePlex, I have had to change the TFS server that one of my projects is hosted on. I found this to be a problem because I wanted to use the same directory for the source on my local drive. Even after removing the source control bindings and removing the TFS server settings, Visual Studio still complained that the directory is configured for the old server address.

TFS stores workspace directory mapping information in a VersionControl.config file located in _C:\Documents and Settings[YOUR PROFILE]\Local Settings\Application Data\Microsoft\Team Foundation\1.0\Cache_. The old server isn’t removed from this configuration when you remove the server from TFS in Visual Studio. This bit, you have to do yourself.

Read More

Does the WorkflowRuntime have a memory leak?

Over the last week at work, we have been doing some testing of our WCF services that call into a business layer that uses WF. We have the services set as single instance, and we are using a new instance of the WorkflowRuntime for each service call. There are obvious inefficiencies of creating the runtime for each call, but that isn’t the issue. The problem is that we noticed that the memory went up and didn’t get released (until the AppDomain was unloaded).

After a lot of testing, it came down to the WorkflowRuntime instances that were remaining in memory, even through all of our other objects were cleaned up and disposed. We did everything we could to release the runtime from our code but the memory issues remained. So, is there are memory leak in the runtime?

The solution seems to be to wrap the runtime as a singleton. Singletons have been bashed a lot over recent months and while I agree with the criticism over the misuse/overuse of singletons, I think this is an appropriate case for one. Initial testing has shown that there is no memory problems once only a single WorkflowRuntime was used. This also comes with the performance benefit of not having to create and destroy the runtimes for each call.

Scott Allen has some more pitfalls to watch out for with the runtimes.

Read More

How does the GC handle circular references?

I am a little curious about how the garbage collector cleans up CLR objects. From what I understand, it will wait until objects are de-referenced and then will go through a couple of generations (as required) to release objects from memory.

The following is a simple scenario of GC:

Object A that has a reference to B that has a reference to C. When A goes out of scope, the GC can collect it. When it removes A, B is has a reference count of 0 and can also be removed and then likewise for C as B is removed.

Side question: does this happen in the same GC cycle or is this over three GC cycles?

Ok, simple enough. But how does the GC handle the following scenario:

Object A has a reference to B which has a reference to C. C has a reference back to B.

When A goes out of scope, is B available for the GC as it is still referenced by C? How does the GC handle these circular references?

Read More

Shane helps to shape the future

We just had Shane Morris come to my work to spend some time with us talking about UX. There was a statement he made that really stood out. It was something like:

Usability is the natural enemy of functionality. A successful application is usually one with features left out.

Hope I’m not misrepresenting him, but I think this is a really important point, especially when UX is normally a developer responsibility. Developers tend to cram in functionality because that is what the business spec told them to do.

From the developer community, and their managers, I think there needs to be more of a focus on what the final product will become (good or bad) rather than just ticking the boxes to say that we covered all the use cases. I think the key here is to have a change of perspective.

I have often thought that if you have developed the greatest software on the planet, but the UX is terrible, then you really missed the point (and wasted a lot of money/time). UX is just as important as every other piece of the software puzzle. I’m glad that this is becoming a bit more accepted in the industry.

Read More

WF rules and bitwise OR

I have been doing some WF development this morning and came across something interesting. I had a PolicyActivity in which I was trying to assign a bitwise enum value on an object instance. The rules editor gave be an error saying that I couldn’t use a bitwise OR operation on the types of operands I was using. It seems to me that CodeDom doesn’t correctly parse bitwise OR.

From what I have googled this morning, is looks like the WF rules engine is supposed to support it. I wasn’t however able to find any code examples or screenshots of where people have successfully implemented bitwise OR. So at this stage it looks like it is just documented, not actually used.

My workaround was to modify the enum to include a definition of the bitwise value that I require so that the operator isn’t in the rule definition. While this covers this particular scenario, what happens when the enum that I need to use is defined in an assembly that I don’t control?
Read More

Are singletons evil?

This is a very well written post from one of the Readify boys about the overuse of the Singleton pattern. Food for thought. I should look at whether the places I have used singletons is appropriate.

Read More

PC vs Mac

It seems like the blogsphere is getting very busy of late with PC vs Mac (or Mac vs PC, whatever your pleasure) arguments, adverts and mud-slinging. It reminds me of the following video which I originally got via email about three or four years ago.


Read More

Frozen Five -

As my wife and I were traveling through New Zealand last year, we were fortunate enough to met a great Swedish couple (Anna-Lisa and Mats) who we were able to travel with for a few days. On the 29th of March, Mats is going to start a Svalbard Skiing Expedition with a group of other geoscience students from around the world.

As I am in drought ridden Australia with dead grass all around my house, city and state, I find this absolutely fascinating. Anyway, check out their site and blog.

Read More