Improving MFC memory performance

By , January 2, 2012 12:16 pm

If you are using MFC arrays it is possible in quite a few cases to improve the speed and memory performance of these arrays. This applies to the standard CStringArray, CUIntArray and similar classes and also to template classes based upon the CArray template.

If you are not using MFC but using another framework or set of classes that provide similar functionality you can often find similar functions in those classes that will allow you to get a similar benefit to what I will describe in this article.

The Problem

The problem is the typical use of populating the array is by calling the Add() method to add something to the array. No actual problem with that, its simple and straightforward enough. However, under the hood, each time you call Add() the array class has to reallocate more memory of the data stored in the class.

This reallocation has a cost. The cost is increased CPU usage as suitable memory space is searched for by the memory allocator and memory is copied and reassigned inside the class. For small arrays this is not really a problem.

However for larger arrays this becomes quite a noticeable issue. In addition you also run into potential memory fragmentation issues, where memory "holes" of an unusuable size are left in the memory managed by the memory allocator. Should enough of these holes occur you can suffer out of memory conditions even when Task Manager tells you you have available memory. Frustrating! I’ll cover Memory Fragmentation in a different article.

Here is a (simplified) example of the type of problem:

// read data from the serialization archive and store in an array

DWORD i, n;

ar >> n;
for(i = 0; i < n; i++)
{
    someClass *sc;

    sc = new someClass();
    if (sc != NULL)
    {
        sc->load(ar);
        array.Add(sc);
    }
}

The Solution

In the case shown above we know how many objects we require storage for beforehand. This means we can tell the array how many objects to store and only perform one memory allocation to set aside storage for the array. This has CPU benefits and also because there are no repeated calls to reallocate the memory the likelihood of fragmentation occurring diminishes dramatically. In many cases, completely removed from the scenario.

To set the size beforehand we need to call SetSize(size); and to place data in the array we no longer use Add();, but use SetAt(index, data); instead.

Here is the reworked example:

// read data from the serialization archive and store in an array

DWORD i, n;

ar >> n;
array.SetSize(n);
for(i = 0; i < n; i++)
{
    someClass *sc;

    sc = new someClass();
    if (sc != NULL)
    {
        sc->load(ar);
        array.SetAt(i, sc);
    }
}

For large volumes of data the above implementation can be noticeably faster.

Caveats

When you preallocate memory like this you must be aware that if you don’t fill all locations in the array using SetAt() you may get errors when you call GetSize() to get the array size and GetAt(i) to retrieve data.

// read data from the serialization archive and store in an array
// we won't store all data, leaving some unused memory at the end of
// the array

DWORD i, n, c;

ar >> n;
c = 0;
array.SetSize(n);
for(i = 0; i < n; i++)
{
    someClass *sc;

    sc = new someClass();
    if (sc != NULL)
    {
        sc->load(ar);
        if (sc->IsEmpty())
        {
            // discard

            delete sc;
        }
        else
        {
            array.SetAt(c, sc);
            c++;
        }
    }
}

GetSize() will return the size of the array you set when you called SetSize(), this is not necessarily the number of items in the array – this will come as a surprise to people used to adding data by calling Add().

To fix this, use FreeExtra() to remove any unused items from the end of the array. You can also use GetUpperBound() to find the largest index that is used by the array. The example below shows this.

// read data from the serialization archive and store in an array
// we won't store all data, leaving some unused memory at the end of
// the array

DWORD i, n, c;

ar >> n;
c = 0;
array.SetSize(n);
for(i = 0; i < n; i++)
{
    someClass *sc;

    sc = new someClass();
    if (sc != NULL)
    {
        sc->load(ar);
        if (sc->IsEmpty())
        {
            // discard

            delete sc;
        }
        else
        {
            array.SetAt(c, sc);
            c++;
        }
    }
}

// make sure array.GetSize() returns the max number of items used

array.FreeExtra();
Share

Business of Software 2011 – mind food

By , November 22, 2011 10:36 am

A few weeks ago in October I travelled to Boston, MA for the Business of Software conference. This is the number one conference to go to for folks aiming to create a software business to last the long term. This isn’t a place to come if you want to create a Facebook then flip it and walk away with millions. Nothing sustainable about flipping companies.

Twitter seemed to come into its own at and before the conference. People using phones, iPads, laptops to coordinate who they were eating with and when. #BoS2011 became unmanageable. Mark Littlewood’s advice to use Tweetdeck was well received.

Audience

Its a self selecting audience. They’re all very bright, self motivated. A lot of the people attending run their own businesses, from one man companies to some larger organisations like Red Gate who brought a good chunk of their staff with them. 30 people? 50 people? I don’t know. A lot – more than many people have on their entire staff. I spent Saturday evening with 5 Red Gate people and most of Sunday with some more Red Gate folk. It seems that Red Gate is being quite entrepreneurial with its staff – exposing them to conferences like this and training them for the future. It seems like a much more thoughtful vision for their future than most companies take.

Microsoft had some people in attendance too. The only Microsoftee I met was Patrick Foley, who was brave enough to give a Lightning talk. One attendee had travelled all the way from Romania, using three planes to get to Boston. He was probably one of the youngest attendees too. I spent a chunk of Tuesday evening chatting with him in The Whiskey Priest. Not sure I’d have been that keen to travel that far for a conference at age 25. Kudos.

The quality of the speakers was incredible. I thought Clayton Christensen would be the top draw (I’ve read most of his books, found them really interesting) but as it turned out I preferred the speakers on the second day – Rory Sutherland and Josh Linkner in particular. Most speakers manage to weave humour into their talks. I don’t know if this was planned, opportunist or just something you get good at.

Note taking

I typically record each speaker so that I can listen to them again. Unfortunately for me, although armed with loads of AA batteries when it came to record day two they all failed. So I couldn’t record what turned out to be my favourite talks. Next time, purchase the batteries when I get there, don’t rely on them being OK just because they’ve never been used.

Although at MicroConf I took copious notes, I took very few at Business of Software. I was just too wrapped up in what was being presented. When I look at my notes its in my typical unreadable “I should have been a doctor” handwriting, with a good chunk of the notes not about the talk being given but about ideas for improving the software process at Software Verification. Its as if being there was stimulating me to take action over what we will do in future. Part of me is pleased with this and part of me is frustrated I didn’t take more written notes.

The Business of Software goodie bag was unusual – full of stuff I will actually read. Books from some of the speakers. Their talks were interesting, so that bodes well for the books they wrote.

Business of Software Team

The team Mark Littlewood assembled were superb. They were always on hand to help. When I asked them for help with some nuts (I needed protein as the vegetarian food was all carbohydate and had no pulses etc) they to my amazement found some fruit and nuts for me. I expected them to tell me where I could find a shop. Later that evening two of them saw me collasped on a seat at The Whiskey Priest and came over. They wanted to walk me back to the hotel until I explained I’d be alright in about 20 minutes – when my blood sugar had become normal again after eating (I shouldn’t have had the beer so soon after eating with the noise of the Business of Software band – too much).

As well as the BoS team, the conference centre staff were helpful and courteous. Americans really understand service. So often I’ve had bad experiences in the UK.

Clayton Christensen

Clayton Christensen’s talk was pretty much a summary of his Innovator’s Dilemma book. Given that I’ve read his books I didn’t talk many notes. I think the standout items for me were:

  • The customer rarely buys what the company thinks it is selling him.
  • You should be focussing on “What is the job to be done (by the customer)?”.
  • Look to the bottom of the market, that is where the innovation will come.

The second point is really telling. Most companies create products they try to sell to customers. They don’t actually research what it is a potential customer is trying to do. Are you really trying to buy a car or just go from A to B conveniently? If its the latter a car may not be the best thing to sell them. On this point, in Cambridge, UK, there has been a rise in the number of people ditching their car and switching to electric bicycles. Job to be done is commuting around town. You don’t necessarily need a car for that.

This third point was illustrated nicely with the example of solar power. In the USA and Europe we have government grants creating solar power and wind farms. But that is trying replace the existing fossil fuel based systems with intermittent solar and wind power. But if you go to Africa and parts of Asia where there is an underserved market (people with little or no power supply) then an intermittent supply of solar and wind is more useful than no power supply. It is in these markets that new technologies to improve the intermittent power supply (with better battery technology for storage and better solar cell technology for improved generation, etc) can flourish. Eventually these technologies will get good enough to start competing in the more traditional markets for power in the Western economies. The key thing is that the economic drivers are in the underserved markets, not in the well served markets.

More Information: http://www.claytonchristensen.com/

Jason Cohen

Jason Cohen talked about Honesty and how companies misrepresent themselves to make themselves appear different from reality. A bit like a bird puffing up its chest to look more intimidating we write our about pages to appear different than we really are.

Jason argues that this is dishonest and misleading and that by being honest it is more profitable in the long run (and feels better). Jason also argues that by being candid about what you can and cannot do you also inform your customers better than the one-sided comparison charts (where every feature your software can do is listed and only your software gets a tick mark next to everything).

Jason sold his previous company and now runs a WP Engine. WP Engine is smaller than most of his competitors and as Jason admits, he isn’t the cheapest solution. However he believes that by being candid about your strengths and weaknesses your company size doesn’t have to be a weakness. You size means you need every customer, thus you must focus on them. Contrast this to the approach you get from Big Corp, where you are a faceless customer and often get treated like one.

I wrote two quotes during the talk:

  • “Truth in limitations earns believability advances”.
  • “Open source is free like a puppy is free”.

I had two todo items on my list at the end of this talk and a big note saying I must re-listen to this talk when I get home. It made an impression. Dave Collins from Software Promotions was so impressed he wrote a post about it then posted the before and after About pages so you could see the difference.

More information: http://blog.asmartbear.com/

Alex Osterwalder

Alex Osterwalder gave a talk on Business Model Generation. I had thought Alex’s talk would be boring. And talking to some people later on (in the UX class lead by Richard Muscat) it appeared some other attendees also thought that. How wrong we were. One of the books in the goodie bag was Alex’s book on Business Model Generation.

On the face of it the title “Business Model Generation” sound rather dry. Alex demonstrated how to use a simple business model canvas to enter simple facts and figures about your business then use those to create other information you could use to see if the business is viable. If not viable, change some parameters and see if the new model is viable. It was surprisingly simple and easy and by the end of the talk I got the impression people wanted more.

To demonstrate a business model Alex used the Nespresso coffee making machines as an example.

  • The machines are sold in retail outlets.
  • Most of the profit from sale of machines goes to the business partners.
  • Nespresso make their money from sales of the coffee pods by mail order, nespresso.com, call centers and from nespresso stores. These are all distribution channels owned and controlled by Nespresso.
  • This allows Nespresso to keep all the recurring margins.

This talk also introduced the audience to Stattys, a non-sticky note that uses static electricity to stick to things rather than glue. After Business of Software Paul Kenny resorted to some awful puns because he liked Stattys so much.

Later on I was in the UX workshop (where we redesigned Business of Software) and talking with other attendees I found that my subgroup in the workshop all wanted to be in the Business Model Generation workshop but all of us had excluded that workshop because we thought it would be boring. None of us held that opinion after Alex’s talk.

Alex also demonstrated his iPad application which is a software implementation of the business model canvas. Looks quite slick and certainly an easy way to create and explore different business concepts.

More information at http://alexosterwalder.com/

Dharmesh Shah

Dharmesh spoke about customer retention and how to measure it, and pricing.

4 Churn Types:

  • Customer. e.g. 5% 5 out of 100.
  • Revenue. e.g. 10% 20K out of 200K.
  • Discretionary. People cancel their account.
  • Involuntary. Billing failure causes cancellation.

At Hubspot they use the Custom Happiness Index 2.0. This predicts how well the customer uses the software.

Dharmesh argues against Freemium pricing as this is a sunk cost. Instead if you want to do Freemium but without the sunk cost you should do Cheapium which is where you charge the customer the cost of supporting them. You don’t make any profit with Cheapium, but you also don’t lose money with Cheapium and you may convert some Cheapium customers to paid customers.

You need humans to sell Complex Products, New Products and products where the price is somewhat high (which Dharmesh defines as greater than $100/month). The point of indifference for most customers is between $30/month and $40/month.

More Information: http://onstartups.com/

Jeff Laswon

Jeff Lawson gave a talk on “Saas Mating Calls” and value as perceived by the customer.

I don’t have many notes on this talk. The talk was somewhat ruined by a couple of people persistently talking behind me until I take no more and asked them to leave or shut up. I was so wound up by this point that I couldn’t really concentrate on Jeff’s talk. I found out later that many other folk had also been annoyed by these two people (perhaps they had not spent their own money to attend?).

So, sorry for no notes worth commenting on.

Tobias Lütke

The last talk of day one was by Tobias. Again, I don’t really have many notes. I think I was struggling with low blood sugar.

Tobias talked about the culture of your company. What sort of company do you want to build?

“Do not start a company to make money. Start a company to delight customers.”

Patrick McKenzie

Patrick McKenzie talked about sales funnels and A/B testing. He also revealed an engagement ring he was going to present to his girlfriend when he returned to Japan.

Sales Funnels:

  • Describe the Funnel.
  • Measure the Funnel.
  • Optimize the Funnel.
  • Profit!

Shorter funnels are better. Analyze your funnel. If you can find any un-needed steps in the sales funnel, remove them.

A/B Testing places:

  • Home Page
  • Landing Pages
  • Pricing Page
  • Shopping Cart

Test the following:

  • Headlines
  • Offers
  • Calls to Action
  • Prominent graphic elements
  • Important micro-copy – address customer objections.

    Example “Don’t worry, we won’t spam you” next to an email address field.

Patrick recommends doing the A/B testing yourself so that you have the test data, but if you don’t want to do that use Visual Website Optimizer (Note: Dharmesh also said Visual Website Optimizer is good when I talked to him about Hubspot – even though Hubspot now has Performable’s A/B testing suite). Be systematic about A/B tests. It works. He says it “prints money”.

Purchasing page
Change your purchase page to do purchasing only. Remove all un-necessary links from the purchasing page so there are no distractions. I suspect this advice is much more important for B2C websites than B2B websites.

First run experience
Collect first run experience statistics. How many people run your software once? How many people run it twice?

If you know the search terms for an evaluating customer find a way to provide customised startup help for that search time on the first run of the software.

Tour Mode
Find a way to provide an interactive tutorial to lead people through the steps to use your software effectively. This is called Tour Mode.

Telemetry
If you do gather telemetry from your desktop software be sure to ask the user’s permission to send that data back to your servers.

More Information: http://www.kalzumeus.com/

Laura Fitton

Laura talked about how your communication to your customers and potential customers should Be Useful.

Be Useful. Its not about you. http://inay.org

Laura advocates a sequence of actions you can use to be more useful.

  • Listen
  • Learn
  • Care
  • Serve
  • [repeat]

Laura’s presentation is on www.slideshare.net/pistachio.

Recommended book: Content Marketing for Startups by Dan Martell.

More information: hubspot.com/pistachio

Josh Linkner

Josh Linkner is VC. He didn’t talk about funding or finance. He gave an excellent talk on unleashing your creativity. His book Disciplined Dreaming was part of the Business of Software Goodie bag.

Josh started by giving a background to creativity and explaining that although most of us think we are not creative, creativity is 85% learned behaviour.

Blocks to creativity are fear. Fear of failing. Fear that the idea/design won’t be any good. I’ll also posit that for a few people, they are afraid the idea/design will succeed and they will have to follow through.

Be curious. Make a point of being curious. Ask Why? Why if? Why not?

“Fail more to win more.”

Do not criticise small mistakes.

Encourage experiments, tolerate failure.

Remarkably Different
Josh gave an example of an unusual and creatively inspired business – http://www.littlemissmatched.com/ – where you can only buy socks in odd numbers. The socks don’t match and you can’t buy pairs. It’s a roaring success. It’s remarkably different.

5 Whys
Josh recommends using the 5 Why’s technique. Ask “Why is this?” about the topic. Then repeat for the answer. Do this 5 times to get to different insights about what you are looking at. This technique is used in quality control, user experience design and other fields. You can use it creatively too.

Learned behaviour
Josh demonstrated learned behaviour by describing an experiment known as The Pike Syndrome where a carnivorous fish (A Pike) ignores the prey fish because it had earlier learned that it was unable to eat them. In the same way, although creative during childhood, many things during our adolescent years and adulthood teach us not to be creative. But you can learn to be creative.

Role Storming
Another technique Josh uses to encourage people to be creative is to “Role Storm”. This is where you take on the role of a particular person or character and approach the problem from their point of view. For example what would Business of Software be like if Darth Vader hosted it? What benefits and features would he be interested in? What sort of user experience would Darth Vader be expecting?

Captcha
Josh demonstrated an alternative form of captcha that relies on understanding a caption and then acting upon it with a simple game. The layout of the game changes on a regular basis as do the captions. This makes it almost impossible for a bot to defeat the captcha. The example given was “Drag 3 peppercorns and 2 mushrooms onto the middle pizza”. It’s an inspired bit of creativity by taking the original problem and re-framing it.

Suggestion
Take 5% of your time (2 hours) to be creative each week. You will be more productive.

I’ll be posting more on creativity as I compose tunes and people always ask me how I do that as it must be so hard and complex. Wrong! Its easy. Anyone can do it.

More information: http://joshlinkner.com/

Rory Sutherland

Rory Sutherland is Vice Chairman of Ogilvy, the advertising giant. Rory gave a talk about Praxeology, the study of human action. Rory talked about how creativity and rational thinking don’t necessarily go hand in hand. Rory was hilarious and the talk full of interesting nuggets.

I’m afraid my notes don’t do justice as I appear to have written short snippets to jog me into performing Google searches. As such I’ll list the phrases here and if any of them jog your mind or cause you to search then that is more use than me trying to frame them for you.

Creativity is policed by rationality but rationality is not policed by creativity. This can lead to very creative people being prevented from being creative but leave rational people to create things like the finance and banking meltdown that happened a few years ago and which we are still living through now.

Chunking
If you want people to finish a task, split the tasks into chunks. People are much more likely to complete all tasks if approached this way.

You want your customers to avoid disappointment or complete surprises.

Rory introduced Ludwig von Mises and the subject of Praxeology.

Do not distinguish between subjective and tangible value.

Availability
Signalling
Handicap
Hueristics and biases
Framing, comparison and content
Immediacy
Loss

Information asymmetry and commitment.

Satisficing vs Maximising.

Make choosing easier
Choice making is easier with 3 items than with 2 items. Put the best choice in the middle and create cheap, average, expensive choices. Most people will choose the middle one.

Framing
Framing is all about the context in which you see the offer. Every thing is relative.

Reduce web steps from three to two improves conversion by approx 40%.

Resolve discomfort and disquiet to improve sales.

Behaviours lead attitudes.

Book: Ash Murya.

Lightning talks

I didn’t take any notes on the Lighting talks.

The most memorable talk for me was Tyler Rooney’s talk about the failures he witnessed and experienced at Amazon. The most hilarious being someone nobbling the companywide internal DNS, which killed everything. Including killing the IP-based telephones so that nobody could contact anyone to tell them to fix the problem. Sometimes economies (like purchasing IP based phones) are not economies.

Justin Goeres won the Lightning talk competition, so I never did bump into him (we were going to go for a meal later) because he was invited to the Speaker’s Dinner. Would he pass that up for a meal with me? No… :-) We finally met up at breakfast the next morning.

Michael McDermott

The next talk was about being a design dictator at Fresh Books. I didn’t take any notes. I think I was struggling with low blood sugar.

Fresh Books is a good product. We use it.

John Nese interviewed by Peldi

The final talk of day 2 was John Nese, the owner of an independent Soda Pop store being interviewed by Peldi. The interview was prefaced with a video. John Nese was fantastic. The little guy going against Big Corp (in the form of Coke and Pepsi). He had passion to spare and a true depth of knowledge about the products he sells, strong opinions on stuff he doesn’t like (Energy drinks and stupid recycling laws).

After the talk everyone was talking about him. Strong resonance between what he had to say and how most people felt business should be done (rather than how it often is done).

Paul Kenny

Paul talks about how to close a sale. How not to leave the sale dangling and how to not ruin the close by closing in the wrong way. Closing is a soft skill and not something that you can deal with in terms of cold hard data.

How many people in the audience are founders? Lots of hands. Good. “You are a founder. Therefore you are a salesperson.”

“The result of a business is a satisfied customer.”

How not to do it: Alec Baldwin (always be closing).

Closing is asking for a commitment. Commit to what?

  • Concept
  • Action
  • Purchase

Asking avoids the decision making process. (can’t read my handwriting, I think it says “avoids”).

Mistakes:

  • Ask the wrong way at the wrong time. (push)
  • Fail to ask the right way at the right time.

People are pushy when the have only one way of asking.

Once you have asked for your commitment, shut up and wait for the answer.

David Cancel

David Cancel talks about A/B tests. David’s company Performable was acquired by Hubspot in late 2010/early 2011.

Failing is good. It is OK to fail. You learn by failing.

He recommends having a business dashboard so you can measure your company’s health.

All initiatives should show improvement.

Use the Net Promoter Score to measure satisfaction.

If using multi-variate tests, don’t bother if you are a small company.

David thinks 2% is average percentage conversion rate. (this is out of context).

Alexis Ohanian

Alexis Ohanian talked about different ways of making the world suck less.

I didn’t take any notes in particular except to remind me to give some of my time away to a local charity.

He also gave away an Apple MacBook. The two people that came up with winning entries both said they didn’t want or need the MacBook, so it was given away to a public school in Melrose, Boston and a local programmer has agreed to teach at a local class.

Workshops

I attended two workshops at Business of Software.

The first workshop was by Richard Muscat from RedGate. This was a user experience workshop where we created user empathy maps for one member of a group of 5 or 6 people. Our workshop had about 30 people so we divided into 5 or 6 teams and redesigned Business of Software conference. The feedback from this workshop was given to Mark and the BoS team.

The second workshop I attended was with Dirk Paessler on the topic of “what do people do to keep their business online”. I had hoped to attend Nemo Chou’s workshop but it was cancelled at the last minute. As such I chose Dirk’s because I thought it may be interesting even if not directly related to what I do. It turned out to be surprisingly interesting, if only because of the extraordinary lengths Dirk’s company has gone to ensure it remains online. I got quite a few business specific takeaways from this workshop.

Coming home

Krishna Kotecha, Patrick McKenzie, Corey Reid, Patrick Foley, Levi Kovacs, Tyler Rooney

After conference everyone had a chance to grab some food, possibly be interviewed by the roving cameraman. He got me. I don’t think I made a very good subject. I think you’re either good at this or not. When asked a question that required a thoughtful answer I should have paused and thought. But no. So a bit of a disaster on that front. I’m sure other people had better things to say to the camera than I did.

I milled around for a bit then a group of us headed off to a local restaurant for some pre-flight food. Mark Littlewood said he’d come and join us, but he took so long he met us on the way back to the hotel. Better luck next time Mark.

The photo shows (left to right) Krishna Kotecha, Patrick McKenzie, Corey Reid, Patrick Foley, Levi Kovacs, Tyler Rooney.

TODO List

My notes are littered with TODO items scrawled done as a speaker sparked something in me. On the plane home, reflecting on the conference, I found that every few minutes I’d have to write something down. In total I have about 4 pages of TODOs, 1 per line. Thats about 120 items to do or research. All directly from attending the conference. Not all of the TODO items were new to me at the conference, but the conference reinforced my pre-existing thoughts and coallesced them into an action point.

Conclusion

If I could summarise Business of Software into a few words, it would be “Incredible mind food, stuff to think about for a long time”.

Would I go again? Yes.
Am I glad its on the East Cost of America? Yes. 5 hours out is one thing. 8 hours out another altogether.

Share

Important changes to how we bring you software updates

By , November 17, 2011 11:36 pm

In this blog post I’m going to tell you about some important changes that will be happening with respect to how we provide software updates to the people that use our software tools.

Software Update Email Notification

At present customers that have purchased our software tools receive software software update notifications via email. In addition participants in our beta software programmes also receive software update notifications via email.

Software updates are released whenever we have bug fixes we think should be released or whenever we have new functionality we wish to make public. This can result in releases on a day by day basis or no releases for weeks at a time. We never hold bug fixes or releases back for service packs. We always try to get them to our users as rapidly as possible.

For some people the constant email notifications are too much and they ask not to be notified any more. For other people they welcome the fact that we supply bug fixes and updates on a regular basis. Clearly there is no one-size-fits-all solution to email notification.

Another problem is bounced email. Sometimes valid email addresses bounce. Do we unsubscribe this email automatically or do we try it again the next time (because quite often these email addresses spring back into life)? Either way, over time we end up building a large list of dead email addresses.

Automatic Software Updates

Starting next week, we’re going to release new software versions which are capable of self-updating. These new releases will check for the availability of a new release, prompt you to ask if you are interested in the new release and if you are, login to our server, download the software, install the software and new license keys and then restart the software.

Software Maintenance

In addition to the ability to keep the software up to date it will also be possible to update the software maintenance from within the software update package. As such you will always know when the software updates are about to expire and when you need to renew your software maintenance.

When you purchase your software tools from us we always provide you with at least one year of software updates as part of the purchase. Up until now we have never enforced that. We have provided software updates for periods much longer than one year for some customers. With this new functionality we will continue to provide one year of software updates but we will now enforce that period from January 15 2012.

As such if you’ve purchased since a year of January 15 2011 your software maintenance will continue for a year from the purchase date. If you purchased before January 15 2011 your software maintenance will need renewing on January 15 2012. Two examples should demonstrate this:

Example 1:
Purchase date: 2009-10-31
Maintenance expiry date: 2012-01-15
Example 2:
Purchase date: 2011-08-31
Maintenance expiry date: 2012-08-31

The reason for this change is because there is a cost to us to provide the software updates and we can no longer provide these for free. We always intended to charge for software updates but for various reasons never got around to do it. Thus some of you, our customers, have had a very extended period of software updates without a maintenance fee.

As of the next software update, the only way to receive updates will be via the self-updating software updater. We will not be sending out software update emails after the next update.

For beta test participants, the maintenance expiry date will be adjusted as the beta test progresses. There will be no maintenance fee for beta test participants.

How does the self-updater work?

Software update menu

We’ve added two menu items to the Tools menu in all full product and beta versions of the tools. These options allow you to edit the schedule when the tool will check for software updates and also to force a check for software updates.

In order to accommodate different working styles we’ve provided a variety of different update options so that the disruption to a given software developer’s workflow is minimized.

The software update schedule can be set to check for updates every day, every week, monthly or not at all. This check is performed when the software is first started on a given day. This means that people running multiple day tests (say doing regression testing on a large test suite) will not be interrupted by a software update prompt. We think that given how the tools are used they are typically not kept open for extended lengths of time and will typically be started when needed. As such checking once during startup is a suitable event to check for software updates.

The date of the most recent check is displayed on the schedule dialog.

If you wish to force a software update just choose “Check for software updates…” on the menu.

Software update schedule



When a software update is available the user will be prompted with a confirmation dialog providing the choices to download and install the software, to ignore the download until later or to ignore the download completely.

Options for editing the update schedule or purchasing additional software maintenance are also provided.

Software update yes, no, skip selection

If the user chooses to ignore the download they will be prompted about this download (or a subsequent download) at the next software update interval (the next day, next week, or next month).

If the user chooses to skip this download they will only be prompted to download if a new software version becomes available for download. Should the user change their mind they can always choose to force a check for updates using the menu “Check for software updates…”.

If the user chooses to download and install the software, the tool contacts the server and logs in using the user supplied credentials (provided when you purchase the software or join a beta test). If no login credentials have been supplied the user is prompted for the login credentials.

Software update login details

Once logged into the server the software downloads the software with progress shown on a download progress dialog.

Software update login details

When the software is downloaded successfully the tool will close and the software will be installed. Finally the tool is restarted so that work can continue with the tool.

Expired Software Maintenance

Software maintenance has an expiry date. The software continues to work but the ability to receive software updates ceases at this date. When software maintenance has expired a software maintenance expiry dialog is displayed. The user of the software has the opportunity to purchase additional software maintenance to continue receiving software updates.

Software update expired

Software Maintenance Pricing

Given that I’ve discussed purchasing maintenance I should just briefly cover maintenance pricing otherwise you may decide to spend time scouring the website for maintenance pricing. To save you that effort here is the brief summary.

The software maintenance fee is 25% of the listed purchase price on our website. This excludes any special offer pricing. This means that if you received a volume discount when purchasing the software the maintenance fee automatically includes the same volume discount pricing.

The easiest way to purchase this will be by clicking the appropriate purchase buttons on the software. They will log you into the website, choose the correct product and correct number of users and price etc, all automatically. And when the purchase is complete the correct account and expiry details will be updated. Much easier than trying to do this any other way.

Conclusion

This new method of providing software updates will be less intrusive (much less email) and more customizable (you can choose the update schedule). We hope you will find this a useful improvement to our current software update schedule.

Be sure to look out for the next software update email from us. You’ll need to download that software update to get the version of the software that can self-update as described in this article. If you wish to continue receiving software updates you will need the next version of our software tools.

We welcome your thoughts and comments on these changes.

Share

Tablets vs PCs, is this the correct way to compare them?

By , October 21, 2011 11:54 am

A brief history

Since the dawn of electronic computing we’ve had valves disrupted by transistors, mainframes disrupted by minicomputers, mincomputers disrupted by workstations, workstations disrupted by PCs and PCs disrupted by notebooks and netbooks. The latest entrant is the tablet computer.

Tablets were initially a failure, mainly due to desktop operating systems being forced to do a job they were ill suited to do. However the Apple iPad changed all that. A new way of considering how to use a tablet. This has spawned a lot of imitators, mainly based on Android. Microsoft will also be entering the fray with Windows 8 and the Metro UI. Microsoft is making the reverse mistake though – forcing its tablet UI on its desktop users. So it may succeed in the tablet space and then fail in the desktop space. We shall see.

Disruptive or Complementary?

Having set the scene the next question is are tablets going to be disruptive to PCs or complementary? Some people seem to think its a straight fight between PCs and tablets – that tablets are going to disrupt PCs and ultimately replace them. Even Professor Clayton Christensen, author of many books on industrial disruption thinks this is going to happen. His latest tweet on the subject “The value of theory: you know that iPads will cannibalize PCs long before the data tells you it’s happening http://bit.ly/nlSq2l #disruption”.

I’ve read most of Professor Christensen’s books on disruptive innovation theory. I think the case is well argued and I find the books fascinating and engaging. I think I do understand the theory correctly. There is always room to improve my understanding.

But I don’t agree that just because iPad shipments exceed PC shipments its the end for the PC. Not even a long way into the future. When I say PC I’m talking not just Windows, but Macs and Linux boxes etc. Anything that sits on your desktop, under the desk, or a portable computer like a laptop, notebook or netbook.

I think tablets are in the main, complementary to PCs. By complementary I mean that they are providing opportunities in places where a PC is not practical or appropriate. I do think tablets will erode some consumer use of PCs. I do not think tablets will replace PCs in the business world.

Tablets

Tablets are great for passive consumption of data. For example, viewing movies, reading email and writing occasional replies, viewing websites, playing games, viewing 2D and 3D models. Touch screen UIs excel at the consumption of content.

Tablets will almost certainly gain traction in areas where you want to view business data. RedGate software’s SQLMonitor is a great example of this.

Tablets will almost certainly gain traction in areas where you need to update the status of items but do not need to type extensive reports. A scenario for this would be in hospitals. Keyboards are a haven for bugs as they are hard to clean effectively. Tablets are smooth and easy to clean. Tablet touch screens are perfect for this type of work – well designed user interfaces will minimise the need to type and make a tablet usable in this situation.

The above two scenarios are not really tablet vs PC scenarios. They are complementary. The tablet is enabling a business activity that the PC either did badly, or could not do at all. For the SQLMonitor example, the tablet is doing the job better than the PC, is is more convenient. But this is a data consumption task (as opposed to content creation). In the hospital example, no one carries a laptop to the bed of the person they are seeing and then checks off their health and medication as they do their rounds. But I can easily see that happening with a tablet. That is, the tablet is serving an underserved or nonserved market.

But all that said, tablets are not good for any large scale content creation activity. Examples are word processing, accounting, creative work, video editing, audio editing, 3D CAD creation, writing software. All these activities are typically done by professionals with two or more large screen monitors with multiple windows open at once, referencing data in one window, cutting and pasting into another, sometimes having specialised external interaction devices (drawing tablets, styluses, trackballs, joysticks etc). For businesses that need computers the above describes the majority of those computing activities.

The 3D CAD creation item is an interesting one. I know some folks at SolidWorks Corporation. When the iPad came out they created a viewer for it. Have they moved to put SolidWorks on the iPad? No. Its a $4000/seat software product. People use it on powerful workstations with multiple screens with large resolutions. You just cannot replicate this experience on a tablet.

The other interesting point is software creation. When Apple introduced the Macbook, Macbook Pro and Macbook Air computers web developers and creatives very quickly switched to these computers to do their work. Have these people moved to the iPad or any other tablet to do their creative work? If a tablet was suitable for content creation these people would have switched already and be trying to prove it can be done.

PCs

However when it comes to content creation the PC is the place where that will continue to happen.

There are several reasons why PCs will continue to dominate in this area:

  • PCs are designed to be used for content creation. The ability to have multiple windows open, multi-task, source data from one application easily into another application, these are key to being efficient at the job in hand. Tablets just can’t do this. I can’t see this being fixed on a tablet.
  • Multiple screens, with physical screen sizes up to 30″ and pixel counts exceeding 2500 across. Even if you could get a 30″ tablet with 2560×1600 resolution, you wouldn’t be able to lift it and it would be too heavy and too unweildy to rest in your lap when you sit on the sofa.
  • Egonomics. The ergonomics of using a tablet are such that for occasional use sitting on the sofa, lying in bed, etc, they do you no harm. I can speak from my own painful experience with RSI that for extended periods of working a tablet will give rise to all manner of unpleasant ailments. I can see all the problems with poor posture and static loading that did so much damage to me, those problems are all there with the tablet. And those problems will always be there because that is a function of the form factor of a tablet.

In summary at large screen sizes, where tablets could in theory start to compete against a PC, the tablet becomes unweildy, impractical and in ergonomic terms, bad for you. If with advances in materials science – let us say if carbon fibre manufacture became cost effective and e-ink is the future – then the weight element of a large tablet would go away. But you’re still left with the physical size limits of a tablet that is 23″ (or more!) to deal with. I’m writing this on a 23″ screen and I could not imagine trying to sit with this on my lap.

You can improve the touch screen typing of a tablet, but the on screen keyboard will always obscure your work. At present there appears to be no solution to the multi-window aspect of computing that has been so successful on workstations and desktop computers for the last 30 years. Tablets have one window (or with Windows 8 Metro, possibly two) at a time. As you can see in the comments sections of the 4 blogs posts dedicated to the Metro UI and Search on the MSDN blogs, people that work with multiple large screens and many windows absolutely hate being forced to work with one window at a time. I confess that I am one of the many detractors of Microsoft’s new user interface work – it seriously degrades what they are doing.

Conclusion

It is inevitable that for some tasks PCs have been used for (mainly consuming information) tablets may well replace them as the best item “hired to do the job”. But I think there is quite a large section of jobs for which the tablet can never successfully compete against the PC – jobs which require multiple screens, large screens, overlapping windows/displays and specialised data entry devices.

Simply making the tablet larger is not a solution due to physical size constraints. Adding lots of external devices to the tablet (using say bluetooth) kind of defeats the point because then you can only use the tablet in one place – it no longer has the very attribute that makes it attractive (its single object portability) – you may as well use a desktop PC in that situation, it would be better suited to the task.

I think tablets are complementary to PCs. I think tablets are doing a job PCs have never been able to do well. I think PCs do a job that tablets will never be able to do well.

I think this quote from I-DotNET written in the MSDN blog comments Windows 8 Search best describes a tablet.

Touch-screen UIs are not the next generation of UI the way that GUIs and the mouse replaced the command line. Instead, what we’re seeing here is the creation of a brand new category of device, a device that is used differently for different purposes and often by different people. The touch screen UI is simply the UI best suited for this category. No more. No less.

Share

Windows 8 Start Screen disaster

By , October 13, 2011 11:19 am

Over on the MSDN blog there is a series of articles about Windows 8. Among those articles are three articles about the Windows 8 Start Screen which replaces the Start Menu.

Some background

I’ve been a member of MSDN since late 1994 when I first heard about MSJ magazine and then heard about MSDN. I’ve worked with Microsoft technologies for the vast majority of the time since then and pretty much exclusively since 1998. I’ve hated the backwards steps the Start menu took from Windows XP to Windows Vista/7 but the Windows 8 process – well that is such a change that I think this will debut so badly that this will be worse than the reception Vista received.

The Vista machines we purchased we got rid of. We have Vista as virtual machines only. We do like Windows 7 though. That works.

So far, despite repeated trials of Windows 8, all I can say is that it is awful. It is not productive, not for how we work. I don’t care how good it is at touch or how well it does web related home-consumer tasks. None of that helps me be productive in my day job. That is what counts. It is, more importantly, also what counts for my customers.

I want Windows 8 to be a success. That is why I am pushing back so hard against the Windows 8 start screen.

MSDN Blog articles

The first article Evolving the Start menu explains what they did and why they did it. It received a lot of negative criticism. They followed up with a second article Designing the Start screen which completely ignored all the criticism and tried to steamroller the Start Screen as superb. This duly received a lot of further criticism.

There is now a third article Reflecting your comments on the Start screen which is full of information, insights and analysis on how they came to arrive at the Start screen and why they think the Start menu should go away. The problem is the arguments are not convincing.

Menus are inefficient

The first argument is that the Start menu is inefficient. That it requires dextrous control of the mouse to find and select an item (this is true) and that it is slow to do so (also, reasonably true).

Therefore they introduce the start screen which is a 2 dimensional grid of tiles that you can easily find with your mouse etc. The problem is, this is not true. They boast that on screens of 1900 x 1080 resolution you can have 80 tiles.

Whooppee! Er No.

I have a screen of 1900 x 1200 and it has 72 icons on the desktop. Can I easily find the icon I want to launch a program? Yes, sometimes. But most of the time I have to scan the whole thing to find the one I want. And I organised that group of icons. It is not efficient. Sometimes despite knowing what I want is in my list of 72 icons I can’t find it and I give up and go and find it from the Search menu anyway.

And Microsoft want all of us to work this way in future. Yikes!

And of couse when you can’t find it you then have to use the new Search functionality. Which I’ll tell you about now…

Search

The old Start menu had a search function on it. In Windows 2000 and Windows XP this was really efficient – you could tell it where to search, what to look for in a document all before starting the search. No time wasted.

In Windows Vista and Windows 7 this was awful, very inefficient. You had to start a search you knew would fail, then bring up the search widget, choose custom and flail around in that awful user interface then get the search (with no progress indicator showing which directory was getting searched – we had that in W2K and XP).

The new Windows 8 search function – there isn’t one. Wait, there is. Just its invisible. Which is why I didn’t know it exists. Its that discoverable that an MSDN member of 17 years could not find it.

Yes, I know I know, I must be an old fart, but seriously. If I can’t find it can my parents, can my girlfriend, can the people working in the Vetinary surgery down the road? No they can’t.

To use search in Windows 8 you have to switch to the start screen and then type. That’s right type into nothing, just type. Apparently this nonesense is inspired from mobile phones. Thats great. Except it isn’t. I’m happy with that metaphor on a phone. But I want my PC to behave like a PC. What is efficient for one device is not efficient for another. If that were true we’d control aircraft the same way we control submarines. Unsurprisingly we don’t.

Furthermore when you switch to the Start menu to make your search you lose the context of your work – so god help you if were hoping to read some text from a website or a document to type into the search widget. How efficient is that? They just made you add an extra step – you now have to copy and paste the text from the website or document. What? The text isn’t copy and pastable? Oh dear, no you’ve got to copy the text off the document onto some paper, switch to the Start screen and then type what you’ve written on paper into the invisible search widget.

Sound exaggerated? Perhaps. But I can see this happening. Especially with less au-fait users like the aforementioned people at the Vetinary surgery (I am actually thinking of some people I know – good with animals, not so with computers – just things to use, on the Desktop!).

But I don’t know what I’m looking for

You don’t know what you’re looking for? So how will you know when you find it? Well, I can kind of remember its name, but not really, but I’ll know it when I see it.

Its like being in a library in the philosophy section and you’re not sure what you’re looking for then all of a sudden you hit the section of Thoreau books and out pops the one you’re looking for. How could I have forgotten its name? Silly me.

Well indeed. And its the same with programs. Often I can’t remember who wrote it (so I can’t select by Vendor) or what its exact name is. My developer machine has 94 menus on the Programs section and most of those have submenus with between 5 and 10 items on. Some have more and some have more submenus. That is a lot of program names to rememeber. Unsurprisingly I don’t rememeber them. I have better things to devote my memory to. But I can browse those menus relatively easily and with reasonable speed.

The main reason I can do that, browse between 450 and 900 items is because each menu only exposes the data under it when I look at it. If I had to look at all 450-900 items at once it would impossible. Most of the items I never look at the submenus, I just have to read the main menu entry and then move on or occasionally check the contents.

It is an efficient compromise between having to use search to search for all executables and then dig through the ridiculous number of results (very slow) and the other extreme where I have to remember them all.

The problem with Windows 8 is that there is no Start menu to browse. I have to use search to find what I want. How can I find what I want when I don’t know its name? Answers on a postcard please (or leave them in the comments section).

Live Updates

A few of the comments in support of Metro in the MSDN blog comments indicate that the poster of these comments thinks that people with views like mine are dinosaurs that can’t see the value of having updating live tiles. What a limited and narrow view.

Such live tiles were previewed in Vista with the gadgets on the screen. Sure they are useful. I haven’t said they are not useful. I have said I don’t wish to work that way. These are different concerns just as some people wish to drive manual cars and others don’t want that chore so they choose an automatic car. In fact that is not a bad analogy, Metro would be the automatic car (less control) and Start Menu users would be driving a manual car (more control).

I have no need for an email tile keeping me up to date with my email. Why? Because I work with 2 computers and three screens. One computer is dedicated to handling email and browsing the web. The other one is for development work. The email machine has an email browser open all the time. Even if I had one machine I’d have the email client open all the time. An email tile is a waste of CPU time for me.

Also, if you know anything about productivity the last thing you want is a screenful of animated tiles doing their thing in your peripheral vision. Nice eye candy for the easily impressed. Boring annoyance for those of us that want to get stuff done.

Ubuntu One

Linux? Who cares about Linux? Why suddenly talk about Linux?

Well they’ve already done this particular experiment for you. The most recent release of Ubuntu comes with the Ubuntu One interface as the default. This is a user interface that makes you access everything via tiles (admittedly more restricted than Metro) and forces you to work with single screen applications.

I first tried it on my netbook. My initial thoughts were that it was good. Web browser and email clients come up full screen (all 800×600 of it!) and I could browse the web OK.

Then a few weeks later I thought I’d install Ruby On Rails on it and take a toy project away with me for a bit of tinkering while on a break. What a disaster. Totally impossible to get anything done in these single whole-screen environments. I spent a good deal of my time in the task switcher moving one window to the front, finding another, then moving that to the front and so on.

That installation of Ubuntu got replaced with the standard Ubuntu classic and all future installations are setup deliberately to exlude Ubuntu One. If you read around the web you’ll find lots of power users also hate Ubuntu One. Just like the power users complaining on the MSDN blog about Metro. You’re taking control (and thus productivity) away from your best customers.

Multi-Screen

The Windows 8 Start Screen covers all your screens. Not user friendly at all. Completely stops any context. As far as I am concerned losing even one whole screen is way too much, especially when you consider how efficient and non-context losing the start menu is.

If the start screen could be encompassed in a resizable window so you could move it whereever you want, or minimize it out of the way that would be useful. This in addition of course, to actually having a proper functioning start menu.

Multi-Tasking

Many complaints have been made about the inability to kill tasks in the Metro interface (all you can do is suspend them). Also the lack of support for multi-tasking windows is a real productivity killer.

These complaints remain un-addressed by the Windows 8 developer team.

No Compromise

The Windows 8 developer team seem completely unconcerned that those of us that want to use their PC to do work do not wish to work in a fashion that is dictated by the needs and desires of those whose only use for a PC is to consume the web/youtube/facebook/email on their tablet or gaming PC.

Both groups of people can be accomodated.

  • Business users. Leave our Windows Desktop alone and give us the Start menu we know and love.
  • Home users. By all means give them the tablet UI you have designed Metro for.

Why can’t this be a configurable option? A powerful Start menu option for folks like myself and the Metro interface for people that think search is a useful replacement for the Start menu.

User Experience

The user experience that I have had with Windows 8 Developer Preview has been extremely poor. Open source operating systems like Haiku give you a better experience out of the box.

Dog Food

I really do wonder if the Windows 8 Developer team is using Windows 8 to develop Windows 8. And I mean everyone, the management team, everyone that has to use office, powerpoint, email, MS Project, all the development team, including people using WinDbg and Visual Studio. I can’t believe they are because the loss in productivity would be huge.

I have to conclude the only people eating the Windows 8 dog food are the home consumer testing group that want a tablet/phone/home-user user interface.

Productivity

I hope that having read this far you realise that the problem with Windows 8 Start Screen is not the start screen itself. It is the drop in productivity and the horrible context switch from Desktop to Start Screen (which itself is a productivity issue) that are the issues. We know what is productive for us. And, although you think you know best for us Microsoft, you don’t.

I’ve already experienced Windows Vista/7 search and hate it. I don’t want to have to use Windows 8 search even more than I already have to use Windows 7 search.

Keep search as what it is good for and allow me to browse for my files, productively, using the Start menu.

Windows 8 #fail

I hope that when Windows 8 finally debuts people can look back at this article and think “Thank God, it didn’t happen, Windows 8 is still productive”.

Otherwise we’ll all be walking around in T-Shirts with the slogan “Windows 8 #fail”.

Share

A new take on tutorials

By , October 5, 2011 3:47 pm

We’ve been making changes to how we present our tutorials for our software tools.

First Steps

Our first tutorials were downloaded with evaluation versions of our tools. When the tool started for the first the tutorial would be shown.

Full versions of the tools did not come with tutorials as we felt this was wasted bandwidth and wasted time downloading material that rarely changed. The tutorial could be downloaded from the website when needed and installed alongside the software.

Second attempt

We recently decided it would be better to host the tutorials on our website. This would allow the tutorial content to be updated at will and thus always provide a better tutorial experience than downloading. This would also make the downloads smaller and thus faster to download.

In addition to this change we have started to introduce video versions of the tutorials. We hope you like it. At present these video tutorials are for C++ Memory Validator. We intend to cover all tutorials for all our software tools.

Creating the videos is interesting – some new tutorial videos have been created as a direct result of creating videos to accompany existing tutorials.

The present

Our latest change is to change how the tutorials are shown to the user of the software tool.

Tutorial tab

The change is that each software tool now has a dedicated tutorial tab. The tab lists the tutorials that are available, with a title, text indicating if the tutorial is text and/or video and the expertise level required for the tutorial. Double clicking on any tutorial topic takes you directly to the correct tutorial on our website.

Each time an evaluation version of a tool is used (and the first time a purchased software tool is used) the tutorial tab is displayed. The tutorial tab can be closed if desired. If the tutorial is later needed it is available from the help menu.

Tutorial close buttonTutorial help menu

We hope these changes will make the tutorials more appealing and more accessible than our previous attempts to inform and educate about effective ways to use our software tools.

Share

The nine types of memory leak

By , September 30, 2011 1:48 pm

Memory leaks affect all computer programs be they desktop applications, service applications or web services. For many trivial applications or applications with a very short application lifetime the odd memory leak is often not of significant importance and will go un-noticed. However for larger applications that use lots of memory or which need to run for a long time (for example web-servers) memory leaks are a serious problem.

Handle Leaks

This article is specifically talking about memory leaks. However handle leaks are just as serious. Not every item in this article has a corresponding handle leak equivalent. However some of the memory leaks shown do have corresponding handle leak equivalents. So if you are concerned about handle leaks, please read this article and just think about handles rather than memory. Most of the examples will apply.

The consequences of memory leaks?

  • Left unchecked memory leaks with ultimately result in the failure of the application to function when requests to allocate memory fail.
  • Memory leaks often mask other problems such as memory corruptions, buffer overruns and buffer underruns. When the leak is fixed these other problems often reveal themselves showing you that the application has more serious problems that also need to be addressed.

Why should you fix memory leaks?

  • Fixing memory leaks often reveals buffer overruns, buffer underruns, memory corruptions, calling functions on deleted objects (which will lead to indeterminate behaviour), multiple access to memory that was freed (incorrect memory access problems). Fixing these problems then results in an overall boost in application software quality, reliability and robustness.
  • Fixing memory leaks improves your application’s memory footprint allowing it to run for longer without errors and failures of operation. This in turn leads to greater user/customer satisfaction.

One proposed solution to memory leaks is to use garbage collection. Garbage collection removes the responsibility of deallocating memory from the programmer. Well, that is the theory. The reality is that garbage collected languages and technologies (.Net, C#, Java, Python, Ruby, etc) can all suffer from memory leaks caused by the programmer forgetting to set references to objects to NULL when they have finished with them. Garbage collection simply changes the cause of the memory leak from forgetting to deallocate the memory to forgetting to reset the reference to NULL. Either way the memory gets leaked. However the fix for deterministic memory leaks is often much easier to determine whereas for garbage collected memory leaks identifying where reset object references is not always so easy.

In this article we are concerned with deterministic memory leaks – the type of memory leak you may get when using a language such as C, C++, Delphi, Fortran, etc – non garbage collected allocations.

We will cover garbage collected memory leaks in another article.

How to deallocate memory.

You should always use the correct deallocator to deallocate memory allocated by an allocator. Array allocations should be matched with array deallocations and single object allocations should be matched with single object deallocations.

malloc free
calloc free
realloc free
_expand free
new delete
new [] delete []
HeapAlloc HeapFree
HeapReAlloc HeapFree
LocaAlloc LocalFree
GlobalAlloc GlobalFree
VirtualAlloc VirtualFree
SysAllocString SysFreeString
CoTaskMemAlloc CoTaskMemFree
CoTaskMemRealloc CoTaskMemFree

Memory leaks fall into one of several categories.

We have identified nine broad categories of memory leak. Some of them are variations of other memory leaks, often with different program scope. We are going outline them all here so that you are aware of them. We will also identify example solutions for each type of memory leak.

#1 Leaked temporary workspace.

This is memory that is allocated inside a function or class method and which is not deallocated before the function completes.

HANDLE createCommsHandle(DWORD	id)
{
	char	*name;
	HANDLE	handle = NULL;

	name = new char [100];
	if (name != NULL)
	{
		sprintf(name, "workstation%d", id);
		handle = createHandle(name);
	}

	return handle;
}

In the above function the memory allocated for the name variable is not deallocated after the call to createHandle().

Solution:

HANDLE createCommsHandle(DWORD	id)
{
	char	*name;
	HANDLE	handle = NULL;

	name = new char [100];
	if (name != NULL)
	{
		sprintf(name, "workstation%d", id);
		handle = createHandle(name);

		delete [] name;
	}

	return handle;
}

#2 Leaked data member

This is memory allocated for use by a class member, but which is not deallocated before the class object is destroyed.

class commsHandle
{
public:
	commsHandle();

	~commsHandle();

	void setName(char	*p_name);

	void createCommsHandle();

private:
	HANDLE	handle;
	char	*name;
};

commsHandle::commsHandle()
{
	name = NULL;
	handle = NULL;
}

commsHandle::~commsHandle()
{
	if (handle != NULL)
		CloseHandle(handle);
}

void commsHandle::setName(char	*p_name)
{
	size_t	len;

	len = strlen(p_name);
	name = new char [len + 1];
	if (name != NULL)
	{
		strcpy(name, p_name);
	}
}

void commsHandle::createCommsHandle()
{
	HANDLE	handle = NULL;

	handle = createHandle(name);

	return handle;
}

The above class has two problems:
#1 the destructor does not deallocate the memory allocated in setName().
#2 setName() does not deallocate the memory allocated in setName() prior to allocating a new value for name.

Solution:

commsHandle::~commsHandle()
{
	if (handle != NULL)
		CloseHandle(handle);

	if (name != NULL)
		delete [] name;

}

void commsHandle::setName(char	*p_name)
{
	if (name != NULL)
	{
		delete [] name;
		name = NULL;
	}

	size_t	len;

	len = strlen(p_name);
	name = new char [len + 1];
	if (name != NULL)
	{
		strcpy(name, p_name);
	}
}

#3 Leaked class static data member

This memory is allocated for use only by many functions of a class, but shared across all instances of that class.

class commsHandle
{
public:
	commsHandle();

	~commsHandle();

	static void setName(char	*p_name);

	void createCommsHandle();

private:
	HANDLE		handle;
	static char	*name;
};

commsHandle::commsHandle()
{
	handle = NULL;
}

commsHandle::~commsHandle()
{
	if (handle != NULL)
		CloseHandle(handle);
}

void commsHandle::setName(char	*p_name)
{
	size_t	len;

	len = strlen(p_name);
	name = new char [len + 1];
	if (name != NULL)
	{
		strcpy(name, p_name);
	}
}

void commsHandle::createCommsHandle()
{
	HANDLE	handle = NULL;

	handle = createHandle(name);

	return handle;
}

The above class has two problems:
#1 setName() does not deallocate the memory allocated in setName() prior to allocating a new value for name.
#2 there is no function to deallocate the memory allocated in setName() – it is not possible to call a function to cleanup this memory allocation.

Solution:

class commsHandle
{
public:
	commsHandle();

	~commsHandle();

	static void flushName();

	static void setName(char	*p_name);

	void createCommsHandle();

private:
	HANDLE		handle;
	static char	*name;
};

void commsHandle::flushName()
{
	if (name != NULL)
	{
		delete [] name;
		name = NULL;
	}
}

void commsHandle::setName(char	*p_name)
{
	flushName();

	size_t	len;

	len = strlen(p_name);
	name = new char [len + 1];
	if (name != NULL)
	{
		strcpy(name, p_name);
	}
}

With the above solution commsHandle::flushName() needs to be called during program shutdown (or at the end of main()).

#4 Leaked global memory

This memory is allocated for use by many functions and is not part of a class.

char *name;

void setName(char	*p_name)
{
	size_t	len;

	len = strlen(p_name);
	name = new char [len + 1];
	if (name != NULL)
	{
		strcpy(name, p_name);
	}
}

Solution:

char *name;


void flushName()
{
	if (name != NULL)
	{
		delete [] name;
		name = NULL;
	}
}


void setName(char	*p_name)
{

	flushName();

	size_t	len;

	len = strlen(p_name);
	name = new char [len + 1];
	if (name != NULL)
	{
		strcpy(name, p_name);
	}
}

With the above solution flushName() needs to be called during program shutdown (or at the end of main()).

#5 Leaked static memory

This memory is allocated soley for use by the function in which is is declared.

void doWork()
{
	static	char	*workspace = NULL;

	if (workspace == NULL)
	{
		workspace = new char [1000];
	}

	...
}

This is a similar leak to #4 except the scope of the memory is restricted to the function (or enclosing scope if declared at a deeper nesting level). The main problem with this allocation style is that there is no easy way to deallocate the memory if the memory is intended to be allocated only on the first call to the function (detected by the if (workspace == NULL) comparison).

Solution:

The solution is to provide an allocation function and a deallocation function. The allocation function getWorkSpace() is called from doWork() and the deallocation function flushWorkSpace() is called during program shutdown or at the end of main().


char *getWorkSpace(); // forward reference

void doWork()
{

	char	*workspace;

	workspace = getWorkSpace();


	...
}


static char *theWorkspace = NULL;

char *getWorkSpace()
{
	if (workSpace == NULL)
		theWorkSpace = new char [1000];

	return theWorkSpace;
}

void flushWorkSpace()
{
	delete [] theWorkSpace;
	theWorkSpace = NULL;
}


int main(int argc, char *argv[])
{
	...

	// end of program

	flushWorkSpace();

}

#6 Leaked worker object

This is when memory is allocated by function X and then passed to function Y to do a job and function X does not cleanup because it expects function Y to cleanup. A common case of this is when a function on one thread creates a data object to pass to a function on another thread.

// code on Thread 1

void processData(DWORD	id,
		 DWORD	tag,
		 DWORD	value)
{
	workerData	*wd;

	wd = new workerData(id, tag, value);
	if (wd != NULL)
	{
		addWorkerToQueue(wd);
	}
}

void addWorkerToQueue(workerData	*wd)
{
	CCriticalSection	lock(&sect, TRUE);

	dataItems.Add(wd);
}

// code on Thread 2

void processQueue()
{
	CCriticalSection	lock(&sect, TRUE);
	DWORD			i, n;

	n = dataItems.GetSize();
	for(i = 0; i < n; i++)
	{
		workerData	*wd;

		wd = dataItems.GetAt(i);
		if (wd != NULL)
		{
			wd->doWork();
		}
	}

	dataItems.RemoveAll();
}

Solution:

The solution is to delete the worker objects once they have been use to do their work.

void processQueue()
{
	CCriticalSection	lock(&sect, TRUE);
	DWORD			i, n;

	n = dataItems.GetSize();
	for(i = 0; i < n; i++)
	{
		workerData	*wd;

		wd = dataItems.GetAt(i);
		if (wd != NULL)
		{
			wd->doWork();

			delete wd;

		}
	}

	dataItems.RemoveAll();
}

#7 Incorrect array delete memory leak

With C++ you can allocate arrays of objects and deallocate arrays of objects. The array form of delete is specified using [] and the non-array form of delete is specified without using [].

class memObj
{
public:
	memObj();

	~memObj();

	... // other functions

private:
	char	*data;
};

memObj::memObj()
{
	data = new [1000];
}

memObj::~memObj()
{
	delete [] data;
}

Consider this object definition that allocates memory in its constructor and deallocates memory in its destructor. On the face of it this does not look like it could leak memory. Well, it can if you allocate it in arrays and deallocate the array incorrectly…

	memObj	*array;

	array = new [10] memObj();

	delete array;

The above code allocates an array of 10 memObj objects then deallocates the array. The space for the array is deallocated but the destructor for each of the 10 memObj objects is only called for the first object. The other nine do not have their destructors called which means that each of the nine memObj objects leaks the memory it holds.

Solution:

	memObj	*array;

	array = new [10] memObj();

	delete [] array;

For instrinsic datatypes and simple objects that have no virtual functions and contain only intrinsic datatypes there may be no real damage by deallocating an array of objects using delete. But that leaves the door open to a memory leak should someone modify the object definition to be more complex or to have virtual functions. Thus you should always deallocate arrays using delete [] (even for intrinsics in case someone modifies the datatype of the intrinsic from say "int" to "complexNumber").

#8 Virtual object memory leak

Virtual functions are used in C++ to provide implementations of a function for an object that is derived from another object. For example an apple object would implement a different flavour() function than a pear object, both objects would be derived from a base class fruit. Objects that are derived from other objects must always have a virtual destructor in the base class. If the base class is not declared as virtual the destructors for the derived objects will not be called, resulting in memory leaks if those objects are meant to deallocate memory.

First we need to define a base class and some derived classes.

class train
{
public:
	train()

	~train();
};

train::train()
{
	...
}

train::~train()
{
	...
}

class steamTrain : public train
{
public:
	steamTrain();

	~steamTrain();

	void addFuel(int quantity);

private:
	coal	*fuel;
	DWORD	amount;
};

steamTrain::steamTrain()
{
	amount = 100;
	fuel = NULL;
	addFuel(amount);
}

steamTrain::~steamTrain()
{
	delete [] fuel;
}

void steamTrain::addFuel(int quantity)
{
	amount += quantity;
	delete [] fuel;
	fuel = new [amount] coal;
}

class electricTrain : public train
{
public:
	electricTrain();

	~electricTrain();

	void powerOn();

	void powerOff();

private:
	pantograph *power;
};

electricTrain::electricTrain()
{
	power = NULL;
}

electricTrain::~electricTrain()
{
	delete power;
}

void electricTrain::powerOn()
{
	delete power;
	power = new pantograph();
}

void electricTrain::powerOff()
{
	delete power;
	power = NULL;
}

Now if we use these object definitions…

	train	*steam = new steamTrain();
	train	*electric = new electricTrain();

	...

	delete steam;
	delete electric;

When the above code is executed the destructor for class train is called for both objects electric and steam. But the destructors for class steamTrain and class electricTrain is not called. This results in a memory leak of the coal and pantograph objects. The reason the destructors are not called is because the destructor for class train was not declared virtual.

Solution:

class train
{
public:
	train()

	virtual ~train();

};

#9 Calling the wrong deallocator

A form of memory leak we’ve seen a few times is caused by the wrong deallocator being used for a given allocator.

char *ptr;

ptr = new char [100];
free(ptr);

HLOCAL loc;

loc = LocalAlloc(LMEM_FIXED, 1000:
GlobalFree(loc);

When you do this different things can happen depending upon what the allocating function was and what the deallocating function is. Possible outcomes are:

  • Memory gets deallocated successfully! This can happen – if the implementation of delete calls free() then some calls to delete will succeed if the memory was allocated by malloc(). We do not recommend doing this. This relies upon implementation dependent details that may change with a future version of the compiler, or change between debug and release builds. This is also a serious impediment to writing portable code should you be writing for more than one operating system.
  • Memory does not get deallocated. Program execution continues as normal and no damage is done to the program.
  • Memory does not get deallocated. Program execution continues as normal but damage is done to heap datastructures in the program. This damage may lead to "random" crashes in your application some time later.
  • Memory does not get deallocated. Program crashes. When this happens you have a strong indicator something is wrong and you may well identify the calling of the wrong deallocator as the cause of the crash.

You should always deallocate using the documented deallocator and if applicable the correct form of array/single declaration (for new/delete and new []/delete []).

Additional types of memory leak

Some programming styles allocate memory once early in the program lifetime and deliberately never deallocate the memory.

static char *longLife = NULL;

// getLongLife called from other parts of the program

char *getLongLife()
{
	return longLife();
}

int main(int  argc,
	 char *argv[])
{
	longLife = new char [1000];

	doWork();
}

This is a one-shot memory allocation intended to last the entire program lifetime because the program authors think the memory may be useful at any stage in the application, including deep inside the program shutdown sequence.

This may happen for some multi-threaded applications where the memory is shared between many threads and for whatever reason the program authors do not think it wise to clean the memory up. One example of this was the lazy allocation of thread local data in earlier versions of Microsoft’s C runtime. The CRT made no attempt to cleanup the memory when the program exited. More recent versions of Microsoft’s CRT have a different behaviour.

Other reasons can be creating workspace for debugging tools injected into a program where the tool expects to try to report data as far into program shutdown as it can go. As such the tool will want its workspace available until the operating system pulls the rug out from under it (which in our experience, is pretty much what happens, if you can fool the OS into letting your DLL last past its DllMain when it would normally be closed you won’t get a second notification that your DLL is going to be killed).

In our experience, although it may be convenient to have a programming style where you can just allocate a whole-application-lifetime object and not-deallocate it this programming style hinders the use of memory debugging tools (by all vendors, not just ourselves) as this whole-application-lifetime object will always be reported as a leak (because it never gets deallocated). That in turn means your memory-leak fix team need to be aware of this object (these objects!) and ignore it. Depending upon your application this can be a waste of developer time.

Much better and tidier to deallocate all memory allocations in every circumstance you can make it happen.

Share

Command line support for .Net services and ASP.Net

By , September 29, 2011 3:59 pm

Today we have released updated versions of our software tools for .Net, .Net Coverage Validator, .Net Memory Validator and .Net Performance Validator.

The updates to each tool add support for monitoring .Net services and ASP.Net processes when working with the tool from the command line. This allows you to, for example, control the tool from batch files and easy create large suites of tests that you can run and control from batch files or using other scripting technologies. This command line support builds on the already existing command line support in each tool for working with .Net desktop appplications. For information on existing command line options for each tool please see the help file that ships with each tool.

I’m going to outline the new command line options for each tool and provide some basic examples of how you might use these options with each tool. Each tool has been given the same basic options, with each tool getting some additional options specific to that tool.

.Net Coverage Validator

  • -serviceName fileName

    The -serviceName option is used to specify which service .Net Coverage Validator should monitor. The filename argument should be quoted if the filename contains spaces.

    -serviceName c:\path\myservice.exe
    -serviceName "c:\path with spaces\myservice.exe"
    
  • -urlToVisit url

    The -urlToVisit option specifies the web page that should be opened by the web browser when working with ASP.Net web servers.

    -urlToVisit http://localhost/myTestPage.aspx
    -urlToVisit "http://localhost/myTestPage.aspx"
    
  • -aspNetName filename

    The -aspNetName option is used to specify the ASP.Net process that is used by IIS. The filename argument should be quoted if the filename contains spaces.

    -aspNetName c:\windows\Microsoft.Net\Framework\v4.0.30319\aspnet_wp.exe
    -aspNetName "c:\windows\Microsoft.Net\Framework\v4.0.30319\aspnet_wp.exe"
    

    The value specified should be the value that you would specify if you used the .Net Coverage Validator interface to work with ASP.Net applications.

  • -webRoot directoryname

    The -webRoot option is used to specify the web root for this ASP.Net process. The directoryname argument should be quoted if the filename contains spaces.

    -webRoot c:\inetpub\wwwroot
    -webRoot "c:\inetpub\wwwroot"
    
  • -webBrowser filename

    The -webBrowser option is used to specify which web browser to use to open the web page if the user has chosen to specify a particular web browser. This option is used when the -aspNetWeb option specifies to use a specific web browser. The filename argument should be quoted if the filename contains spaces.

    -webBrowser c:\mozilla\firefox.exe
    -webBrowser "c:\program files\internet explorer\iexplore.exe"
    
  • -coverageDirectory directoryname

    The -coverageDirectory option specifies the directory .Net Coverage Validator will use to communicate with the GUI if security privileges do not allow named pipes and shared memory usage. The directoryname argument should be quoted if the filename contains spaces.

    -coverageDirectory c:\temp
    
  • -aspNetWeb default|user|specific

    The -aspNetWeb option is used to specify which web browser will be used to open the web page you have specified.

    The options are:

    default Use the default web browser.
    user The user will open a web browser themselves.
    specific Use a web browser identified by a filepath. Use in conjunction with -webBrowser option.
    -aspNetWeb default
    -aspNetWeb user
    -aspNetWeb specfic
    
  • -aspNetDelay integer

    The -aspNetDelay option is used to specify how long .Net Coverage Validator will wait for IIS to reset and restart itself. The delay is specified in milliseconds.

    -aspNetDelay 5000
    

Working with .Net services

This example shows how to use .Net Coverage Validator with a .Net service.

dnCoverageValidator.exe -serviceName E:\WindowsService\bin\Debug\WindowsService.exe
-coverageDirectory c:\test\coverage -saveSession "c:\test results\testbed.dncvm"
-hideUI
  • -serviceName E:\WindowsService\bin\Debug\WindowsService.exe

    This specifies the service to monitor. The service must be started after .Net Coverage Validator has been instructed to monitor the service.

  • -coverageDirectory c:\test\coverage

    This specifies the directory .Net Coverage Validator will use to communicate with the GUI if security privileges do not allow named pipes and shared memory usage.

  • -saveSession “c:\test results\testbed.dncvm”

    This specifies that after the application finishes the session should be saved in the file c:\test results\testbed.dncvm.

  • -hideUI

    This specifies that the user interface should not be displayed during the test. When the target service closes .Net Coverage Validator will close.

Working with ASP.Net

This example shows how to use .Net Coverage Validator with ASP.Net.

dnCoverageValidator.exe -urlToVisit http://localhost/testWebApp.aspx
-aspNetName c:\windows\Microsoft.Net\Framework\v4.0.30319\aspnet_wp.exe
-aspNetWeb default -aspNetDelay 5000 -webRoot c:\inetput\wwwroot
-coverageDirectory c:\test\coverage -saveSession "c:\test results\testbed.dncvm"
-hideUI
  • -urlToVisit http://localhost/testWebApp.aspx

    This specifies the web page that will be opened when working with ASP.Net

  • -aspNetName c:\windows\Microsoft.Net\Framework\v4.0.30319\aspnet_wp.exe

    This specifies the ASP.Net worker process that IIS will start.

  • -aspNetWeb default

    This specifies that the system defined web browser will be used to open the web page.

  • -aspNetDelay 5000

    This specifies a delay of 5 seconds to allow the IIS webserver to restart.

  • -webRoot c:\inetput\wwwroot

    This specifies the web root of the IIS web server.

  • -coverageDirectory c:\test\coverage

    This specifies the directory .Net Coverage Validator will use to communicate with the GUI if security privileges do not allow named pipes and shared memory usage.

  • -saveSession “c:\test results\testbed.dncvm”

    This specifies that after the application finishes the session should be saved in the file c:\test results\testbed.dncvm.

  • -hideUI

    This specifies that the user interface should not be displayed during the test. When the target service closes .Net Coverage Validator will close.

.Net Memory Validator

  • -collectData

    The -collectData option causes .Net Memory Validator to collect memory allocation events until the user chooses to disable data collection from the user interface.

    -collectData
    
  • -doNotCollectData

    The -doNotCollectData option causes .Net Memory Validator to ignore memory allocation events until the user chooses to enable data collection from the user interface.

    -doNotCollectData
    
  • -serviceName fileName

    The -serviceName option is used to specify which service .Net Memory Validator should monitor. The filename argument should be quoted if the filename contains spaces.

    -serviceName c:\path\myservice.exe
    -serviceName "c:\path with spaces\myservice.exe"
    
  • -urlToVisit url

    The -urlToVisit option specifies the web page that should be opened by the web browser when working with ASP.Net web servers.

    -urlToVisit http://localhost/myTestPage.aspx
    -urlToVisit "http://localhost/myTestPage.aspx"
    
  • -aspNetName filename

    The -aspNetName option is used to specify the ASP.Net process that is used by IIS. The filename argument should be quoted if the filename contains spaces.

    -aspNetName c:\windows\Microsoft.Net\Framework\v4.0.30319\aspnet_wp.exe
    -aspNetName "c:\windows\Microsoft.Net\Framework\v4.0.30319\aspnet_wp.exe"
    

    The value specified should be the value that you would specify if you used the .Net Memory Validator interface to work with ASP.Net applications.

  • -webRoot directoryname

    The -webRoot option is used to specify the web root for this ASP.Net process. The directoryname argument should be quoted if the filename contains spaces.

    -webRoot c:\inetpub\wwwroot
    -webRoot "c:\inetpub\wwwroot"
    
  • -webBrowser filename

    The -webBrowser option is used to specify which web browser to use to open the web page if the user has chosen to specify a particular web browser. This option is used when the -aspNetWeb option specifies to use a specific web browser. The filename argument should be quoted if the filename contains spaces.

    -webBrowser c:\mozilla\firefox.exe
    -webBrowser "c:\program files\internet explorer\iexplore.exe"
    
  • -aspNetWeb default|user|specific

    The -aspNetWeb option is used to specify which web browser will be used to open the web page you have specified.

    The options are:

    default Use the default web browser.
    user The user will open a web browser themselves.
    specific Use a web browser identified by a filepath. Use in conjunction with -webBrowser option.
    -aspNetWeb default
    -aspNetWeb user
    -aspNetWeb specfic
    
  • -aspNetDelay integer

    The -aspNetDelay option is used to specify how long .Net Memory Validator will wait for IIS to reset and restart itself. The delay is specified in milliseconds.

    -aspNetDelay 5000
    

Working with .Net services

This example shows how to use .Net Memory Validator with a .Net service.

dnMemoryValidator.exe -serviceName E:\WindowsService\bin\Debug\WindowsService.exe
-saveSession "c:\test results\testbed.dnmvm" -hideUI
  • -serviceName E:\WindowsService\bin\Debug\WindowsService.exe

    This specifies the service to monitor. The service must be started after .Net Memory Validator has been instructed to monitor the service.

  • -saveSession “c:\test results\testbed.dnmvm”

    This specifies that after the application finishes the session should be saved in the file c:\test results\testbed.dnmvm.

  • -hideUI

    This specifies that the user interface should not be displayed during the test. When the target service closes .Net Memory Validator will close.

Working with ASP.Net

This example shows how to use .Net Memory Validator with ASP.Net.

dnMemoryValidator.exe -urlToVisit http://localhost/testWebApp.aspx
-aspNetName c:\windows\Microsoft.Net\Framework\v4.0.30319\aspnet_wp.exe
-aspNetWeb default -aspNetDelay 5000 -webRoot c:\inetput\wwwroot
-saveSession "c:\test results\testbed.dnmvm" -hideUI
  • -urlToVisit http://localhost/testWebApp.aspx

    This specifies the web page that will be opened when working with ASP.Net

  • -aspNetName c:\windows\Microsoft.Net\Framework\v4.0.30319\aspnet_wp.exe

    This specifies the ASP.Net worker process that IIS will start.

  • -aspNetWeb default

    This specifies that the system defined web browser will be used to open the web page.

  • -aspNetDelay 5000

    This specifies a delay of 5 seconds to allow the IIS webserver to restart.

  • -webRoot c:\inetput\wwwroot

    This specifies the web root of the IIS web server.

  • -saveSession “c:\test results\testbed.dnmvm”

    This specifies that after the application finishes the session should be saved in the file c:\test results\testbed.dnmvm.

  • -hideUI

    This specifies that the user interface should not be displayed during the test. When the target service closes .Net Memory Validator will close.

.Net Performance Validator

  • -collectData

    The -collectData option causes .Net Performance Validator to collect memory allocation events until the user chooses to disable data collection from the user interface.

    -collectData
    
  • -doNotCollectData

    The -doNotCollectData option causes .Net Performance Validator to ignore memory allocation events until the user chooses to enable data collection from the user interface.

    -doNotCollectData
    
  • -collectFunctionTimes

    The -collectFunctionTimes option causes .Net Performance Validator to collect timing information for functions in the application/service/ASP.Net webserver.

    -collectFunctionTimes
    
  • -collectLineTimes
    The -collectLinesTimes option causes .Net Performance Validator to collect timing information for lines in the application/service/ASP.Net webserver.

    -collectLineTimes
    
  • -doNotCollectFunctionTimes
    The -doNotCollectFunctionTimes option causes .Net Performance Validator not to collect timing information for functions in the application/service/ASP.Net webserver.

    -doNotCollectFunctionTimes
    
  • -doNotCollectLineTimes
    The -doNotCollectLinesTimes option causes .Net Performance Validator not to collect timing information for lines in the application/service/ASP.Net webserver.

    -doNotCollectLineTimes
    
  • -serviceName fileName

    The -serviceName option is used to specify which service .Net Performance Validator should monitor. The filename argument should be quoted if the filename contains spaces.

    -serviceName c:\path\myservice.exe
    -serviceName "c:\path with spaces\myservice.exe"
    
  • -urlToVisit url

    The -urlToVisit option specifies the web page that should be opened by the web browser when working with ASP.Net web servers.

    -urlToVisit http://localhost/myTestPage.aspx
    -urlToVisit "http://localhost/myTestPage.aspx"
    
  • -aspNetName filename

    The -aspNetName option is used to specify the ASP.Net process that is used by IIS. The filename argument should be quoted if the filename contains spaces.

    -aspNetName c:\windows\Microsoft.Net\Framework\v4.0.30319\aspnet_wp.exe
    -aspNetName "c:\windows\Microsoft.Net\Framework\v4.0.30319\aspnet_wp.exe"
    

    The value specified should be the value that you would specify if you used the .Net Performance Validator interface to work with ASP.Net applications.

  • -webRoot directoryname

    The -webRoot option is used to specify the web root for this ASP.Net process. The directoryname argument should be quoted if the filename contains spaces.

    -webRoot c:\inetpub\wwwroot
    -webRoot "c:\inetpub\wwwroot"
    
  • -webBrowser filename

    The -webBrowser option is used to specify which web browser to use to open the web page if the user has chosen to specify a particular web browser. This option is used when the -aspNetWeb option specifies to use a specific web browser. The filename argument should be quoted if the filename contains spaces.

    -webBrowser c:\mozilla\firefox.exe
    -webBrowser "c:\program files\internet explorer\iexplore.exe"
    
  • -profilerDirectory directoryname

    The -profilerDirectory option specifies the directory .Net Performance Validator will use to communicate with the GUI if security privileges do not allow named pipes and shared memory usage. The directoryname argument should be quoted if the filename contains spaces.

    -profilerDirectory c:\temp
    
  • -aspNetWeb default|user|specific

    The -aspNetWeb option is used to specify which web browser will be used to open the web page you have specified.

    The options are:

    default Use the default web browser.
    user The user will open a web browser themselves.
    specific Use a web browser identified by a filepath. Use in conjunction with -webBrowser option.
    -aspNetWeb default
    -aspNetWeb user
    -aspNetWeb specfic
    
  • -aspNetDelay integer

    The -aspNetDelay option is used to specify how long .Net Performance Validator will wait for IIS to reset and restart itself. The delay is specified in milliseconds.

    -aspNetDelay 5000
    

Working with .Net services

This example shows how to use .Net Performance Validator with a .Net service.

dnPerformanceValidator.exe -serviceName E:\WindowsService\bin\Debug\WindowsService.exe
-profilerDirectory c:\test\profiler -saveSession "c:\test results\testbed.dnpvm"
-hideUI
  • -serviceName E:\WindowsService\bin\Debug\WindowsService.exe

    This specifies the service to monitor. The service must be started after .Net Performance Validator has been instructed to monitor the service.

  • -profilerDirectory c:\test\profiler

    This specifies the directory .Net Performance Validator will use to communicate with the GUI if security privileges do not allow named pipes and shared memory usage.

  • -saveSession “c:\test results\testbed.dnpvm”

    This specifies that after the application finishes the session should be saved in the file c:\test results\testbed.dnpvm.

  • -hideUI

    This specifies that the user interface should not be displayed during the test. When the target service closes .Net Performance Validator will close.

Working with ASP.Net

This example shows how to use .Net Performance Validator with ASP.Net.

dnPerformanceValidator.exe -urlToVisit http://localhost/testWebApp.aspx
-aspNetName c:\windows\Microsoft.Net\Framework\v4.0.30319\aspnet_wp.exe
-aspNetWeb default -aspNetDelay 5000 -webRoot c:\inetput\wwwroot
-profilerDirectory c:\test\profiler -saveSession "c:\test results\testbed.dnpvm"
-hideUI
  • -urlToVisit http://localhost/testWebApp.aspx

    This specifies the web page that will be opened when working with ASP.Net

  • -aspNetName c:\windows\Microsoft.Net\Framework\v4.0.30319\aspnet_wp.exe

    This specifies the ASP.Net worker process that IIS will start.

  • -aspNetWeb default

    This specifies that the system defined web browser will be used to open the web page.

  • -aspNetDelay 5000

    This specifies a delay of 5 seconds to allow the IIS webserver to restart.

  • -webRoot c:\inetput\wwwroot

    This specifies the web root of the IIS web server.

  • -profilerDirectory c:\test\profiler

    This specifies the directory .Net Performance Validator will use to communicate with the GUI if security privileges do not allow named pipes and shared memory usage.

  • -saveSession “c:\test results\testbed.dnpvm”

    This specifies that after the application finishes the session should be saved in the file c:\test results\testbed.dnpvm.

  • -hideUI

    This specifies that the user interface should not be displayed during the test. When the target service closes .Net Performance Validator will close.

Share

To SSD or not SSD? That is the question

By , September 14, 2011 11:56 am

SSDs, or Solid State Disks are fast becoming the thing to have.

With no moving parts they should, in theory, be more reliable than the spinning disks most of us use now. They should also use less power and be faster as well. And in many cases this is the case. But not always. With SSDs you have to be aware of wear levelling – the memory can only be written to a finite number of times before it wears out. Also SSDs are in their infancy compared to the lifetime of the spinning disk industry. As such the reliability issues are not completely resolved.

Operating System

I’ve been interested in SSDs for a while. My first hurdle was that I wanted to use SSDs with Windows XP, but XP doesn’t know about SSDs and thus could potentially wear an SSD out quite quickly with its paging mechanism. Vista and Windows 7 know about SSDs and treat them differently to normal spinning disks so this is not a problem.

SSD user experience

When I went to MicroConf (see the many posts on this blog about that event) I met quite a few owners of MacBook Air computers. These all ship with SSDs. All of them said the same thing – the SSD is the single biggest win for them. To quote one them (sorry, I didn’t get his name) “I had a MacBook with a faster processor but this MacBook Air with a slower processor is a faster computer”. The difference was the SSD. That is quite a statement coming from a developer. He had downgraded his processor but the net result was a better, faster experience due to the SSD.

Talking with other delegates during the conference it was clear that there was quite a bit of interest in SSDs. A bit of research shows that in most circumstances SSD reads will outperform spinning disks greatly and SSD writes will outperform spinning disks greatly. But there are a few circumstances where SSD writes can be very slow and get outperformed by spinning disks. So depending on your usage, SSDs may not be for you. My guess is that for laptop/desktop users SSDs are going to a big win, but server farms with databases writing lots of data may be a problem.

Problems

Despite the wonderful comments from the MacBook Air users I was still concerned about reliability and wear levelling. After some research it turns out that you are more likely to replace your entire computer before wear levelling becomes a serious issue than you are to actually hit wear levelling problems.

That just leaves reliability. This is a problem. When spinning disks die, the controller or an actuator or some other circuitry often dies, leaving the disk completely intact or with minor damage. You can take this to a specialist, pay them some cash and they’ll pull all your data off the broken disk and put it on a new one. Inconvenient, but a result.

With SSDs the notion of cylinder, sectors etc typical of spinning disks goes away. Due to compatibility with SATA and the drop in replacement nature of SSDs these concepts may be used to address the data even though they no longer actually represent a physical location on the disk. The SSD controller maps these values to a virtual location in the SSD memory. That location may change over time to improve the SSD’s performance or to handle wear levelling. With SSDs the controller is typically the failure point and given that the data is spread all over the disk to handle wear levelling and whatever other concerns the controller has you can’t easily identify which SSD locations constitute a file, making it very hard or even impossible to pull data off a dead SSD.

A few weeks ago my father called me to ask if I could help his neighbour with an SSD problem. I could not help. His SSD had died and he had no way to pull many years of family photos from the SSD. And he hadn’t made a backup! Ouch! He’d replaced his spinning disk with an SSD three months earlier. Was really pleased with the performance until one day it just did not work. I’ve found similar tales on the net of server farms taking delivery of cases of SSDs and finding up to 50% dead on arrival!

So with that I’m going to postpone switching to SSDs. I sure could use the speed boost, but just one lost day restoring my data is not worth the effort.

So what else is there?

Turns out there is a solution which has much of the SSD benefits and retains the ability to easily pull data of a dead drive. That solution is the Hybrid SSD. I’ve replaced the spinning disk on this computer with a Hybrid SSD from Seagate. It has a 4GB SSD style data area to read from for all frequently requested data (it learns what apps you use and stores them in the SSD area) but all writes go straight to disk, not into the SSD area. The result is that writes happen at typical spinning disk speeds and reads for random data also happen at typical spinning disk speeds. But programs you frequently run are typically in the 4GB area and start very much quicker.

Also, because it isn’t an SSD you can just use it as a drop in replacement for any SATA drive on any OS – the OS can treat it just like an spinning disk and not be concerned about wear levelling. So you can use it with Windows XP quite happily.

I’ve simplified how it operates greatly, but the end result if I’ve got a snappy feeling machine just by changing my drive to a Hybrid SSD.

Share

How not do to SEO/SEM, lesson #1

By , August 30, 2011 12:58 pm

Today we received this wonderfully attractive offer for a company to improve our Search Engine Optimization (SEO) with their Search Engine Marketing (SEM) services.

I reproduce this in full, edited to change the phone number and icq number to random numbers. What strange things about this communication do you notice?

ONLINE ADVERTISING

Resources:
- SEO - website optimization;
- Banners;
- Context advertising;
- Mass email distribution.

Any type of payment.
Detailed statistics in a personal cabinet.
Great results.

Minimal order starting from $ 100.

please contact us:

Phone:  +1  (2 3 4) -5 67 -8 9 -0 1
icq: 123 456

The email title was Business Promotion, the sender was Glen.

For a company that claims to demonstrate that it is capable of helping you they do some interesting things.

  • Unsolicited email communication to a non-existent email address at our company.
  • Generic Email title
  • No business name to identify who is contacting you.
  • No website URL for you to visit to view the quality of their work.
  • Anonymous contact name (Glen). Even if the person is called Glen you still don’t know their name.
  • Generic email address (in this case gmail) preventing you from identifying the company using the email domain.
  • Telephone number provided with multiple dashes, presumably added randomly to try to hide the number from spam detectors.
  • Various claims of competence but zero way for you to verify that by visiting their website.

Doesn’t that email just inspire you with confidence that the sender of the email can and will do a good job and will do it without using tactics that will damage your business?

This email did in fact get past the email filters, which is how I came to see it. Totally clueless marketing of their service. Although the email inspires me with zero confidence that the purveyors of this service are worth hiring, what if they are worth hiring? Perhaps they can do a good SEO job but just don’t know how to do other marketing properly? Its easy to dismiss them on the grounds they must be clueless based on the email, but if they are good at SEO they are seriously messing up.

Lamb not spam

At the very least in the UK, you need to do the following:

  • Email communication to a real email address at our company. If the email is on topic and relevant then it may not be considered spam by the recipient.
  • Informative, non generic email title
  • Include your business name to identify yourself.
  • Include your full name to identify yourself. Not just your first name.
  • Website URL for your prospective customer to visit to view the quality of your work.
  • In the UK, email communication must also include the business trading address (not the registered address), by law. You also need to list your registered company number if in England or Wales.
  • Optionally include your telephone number.
  • Lastly and most importantly, a relevant message for the recipient.

I’m not suggesting that you spam anyone (far from it), but I am suggesting that if you want people to respond to your email, you need to include a few minimum items in your email. The more things you omit or try to hide (as in the example above) the more red flags you raise that will result in your email being rejected.

BTW. Even if this particular email had been presented to me properly it would have received short shift because it is not relevant for what we want to do. But I thought it was interesting as an example of how badly email communication can be done.

Share

Panorama Theme by Themocracy