Firefox memory blues

I commented on Firefox’s memory leak thats actually a feature a while back and its now cropped up on Coding Horror today. Looks like Jeff suffers from the problem far worse than I do! I tend not to have Firefox open for longer than a few hours, not because of its memory usage, but because of how I work. I switch around between the apps I’m using and close what I don’t need. A sizable majority of my browsing is done in FeedDemon when I’m reading blogs. Thinking about it, if FeedDemon had better tab management I’d probably not use Firefox (or any other separate browser).

BDE and SQL Server 2005

It it possible to use the BDE (version 5+) with SQL Server 2005. But a bit of background first, the BDE is the Borland Database Engine which was (its no longer supported) a key method of getting Delphi developed apps to communicate with various databases such as SQL Server, Oracle, Interbase, Paradox, etc.

The BDE worked as a middle layer between the application and the database manipulating the SQL from the application into the correct format for a given database. The great thing about it was you could write your applications to use the BDE and would be able to support multiple databases (it isn’t quite as simple as that, SQL for one database is not the same for another regardless of what “standards” there are).

In order to talk to SQL Server the BDE uses the DB-Library, a Microsoft developed library, but as of SQL Server 2005 these client drivers are no longer provided with it. However, it does still support them, but only just:

DB-Library – Embedded SQL for C

Although the SQL Server 2005 Database Engine still supports connections from existing applications using the DB-Library and Embedded SQL APIs, it does not include the files or documentation needed to do programming work on applications that use these APIs. A future version of the SQL Server Database Engine will drop support for connections from DB-Library or Embedded SQL applications. Do not use DB-Library or Embedded SQL to develop new applications. Remove any dependencies on either DB-Library or Embedded SQL when modifying existing applications. Instead of these APIs, use the SQLClient namespace or an API such as OLE DB or ODBC. SQL Server 2005 does not include the DB-Library DLL required to run these applications. To run DB-Library or Embedded SQL applications you must have available the DB-Library DLL from SQL Server version 6.5, SQL Server 7.0, or SQL Server 2000.

Source URI’s here and here.

So that means on a client machine you would need to install the SQL Server 2000 client drivers (essentially ntwdblib.dll) along with the BDE. The server can be happily running SQL Server 2005. But there is one further tweak needed to make it all work and that is to set the Compatibility level of the database to SQL Server 2000 (80), as shown below:


Accessible via the Database Properties in Microsoft SQL Server Management Studio.

With that the BDE is more than happy to work the SQL Server 2005. If, however, you set the Compatibility level to SQL Server 2005 (90) you may get error messages of:


The full error message is:

The query uses non-ANSI outer join operators (“*=” or “=*”). To run this query without modification, please set the compatibility level for current database to 80 or lower, using stored procedure sp_dbcmptlevel. It is strongly recommended to rewrite the query using ANSI outer join operators (LEFT OUTER JOIN, RIGHT OUTER JOIN). In the future versions of SQL Server, non-ANSI join operators will not be supported even in backward-compatibility modes.

The problem is that the BDE is sending SQL through that is no longer compatible with SQL Server 2005. You can get round it by tweaking the compatibility level as suggested above, but this should only be done as short term solution. Simply put, its time to stop using the BDE! So Long, and Thanks for All the Fish.

The future of Delphi

You would think with all my waffling on about Delphi apps I would have commented straight away on Borland deciding to spin off IDE development into a separate company early last month. Part of the reason I didn’t was because I wasn’t sure what my thoughts were. Initially I was excited because it would mean better investment and more focused development but that was tempered by the fact that the companies future is currently unknown and that could affect what happens to Delphi.

Borland after the announcement have been annoyingly quiet on the matter. If it wasn’t for Allen Bauer and other Borlanders blogging then we’d be none the wiser as to what was happening. All the posts and comments I’ve read have been positive, which helps inspire some level of confidence. Allen especially has made some excellent posts in recent weeks. He dispelled the Delphi Cash Cow myth and has given progress updates, here and here.

Given Delphi’s strong community I wasn’t surprised to see Marco Cantu and Nick Hodges coming to the fore. Nick has made some great posts and Macro has some interesting ideas but I’m dubious as to whether they’ll listen. I’m all for putting a positive spin on things but I also think you have to be practical. So unfortunately my initial thoughts still stand true.

Where I work has always been a Pascal / Delphi shop and later this year we will be upgrading to Delphi 2006 (and I’m really looking forward to it too!). At which point we’ll be considering our options for .NET development. Whether it continues with Delphi (hopefully) or Visual Studio is as yet undecided. Now its all well and good people posting (on the newsgroups) that statements of switching development IDE are silly, but that can be easily counted by saying that releasing details of a company split without firm details of future plans is equally silly.

We can’t base future development and business plans on words or statements of intent. Actions are needed. Personally I’d have preferred the split to have been kept quiet until something more concrete was in place. Whilst I’d love to believe Allen et al that the next version of Delphi is progressing as planned, I find that hard to believe. As Allen points out, he has spent a lot of time recently in meetings, which to me seems counter productive to developing Delphi.

But this is all hot air, things may be very different in 6 months time. I certainly hope so.

Wrestling with MediaWiki on Windows

I’m in the process of setting up MediaWiki at work (the engine used for WikiPedia) as a test to see if we can use it for our documentation and manuals.

I hit a few problems along the way though, mostly down to inexperience with the software and not RTFMing. For reference I was installing the latest version of MediaWiki (1.5.6) on a Windows 2000 Server box (IIS 4 installed) with PHP 4.4.2 and MySQL 4.1.18. I had three main problems:

  • MySQL / PHP Old Password problems
  • Windows Access Rights / Permissions
  • Bugs in MediaWiki due to PHP on Windows working differently

I’ve hit the MySQL / PHP password problem quite a few times due to college stuff I’ve been doing but never got round to documenting it properly (I have now!). The usual error message you get back from PHP is Client does not support authentication protocol. Basically the problem is that MySQL now uses a new method for password encryption and PHP isn’t compatible with it. I find it a real pain in the backside that they’ve managed to engineer this kind of cock up. You end with passwords being stored that can’t be read properly.

To stop it happening you need to add old_passwords to the [mysqld] section of my.ini. Then restart the MySQL service for it to take affect. If you’re unfortunate enough to end up with broken passwords, the fix is to login to your MySQL database, work out which ones are using the new method and manually fix them. Like this:

  • Get list of users affected: SELECT Host, User, Password FROM mysql.user WHERE LENGTH(Password) > 16;
  • Fix their passwords (one at a time): SET PASSWORD FOR ‘some_user’@’some_host’ = OLD_PASSWORD(‘newpwd’);

The access rights were totally down to me not being awake. I’d remembered to set up script access in IIS, no problem, but I forget everytime to add the correct IUSR_MACHINENAME permissions. You have to add the local machines internet user to have different permissions to various folders (mostly just read access to the entire site, but write access to the images subfolder if you want to upload) and I must have been asleep, because to start with I was assigning the domain controllers IUSR and was wondering why it wasn’t working (by default Windows gives the user list of those on the domain, I should have selected the local machine). Once I got my brain into gear, after about 5 cups of Rocket Fuel, I got round it. 

At this point I was still getting errors on various pages with a PHP blurting out something along the lines of Undefined index REQUEST_URI. Turns out that in PHP for Windows you need to use SCRIPT_NAME instead of REQUEST_URI… obviously. So a bit of search and replace through the MediaWiki source code sorted that out (there were about 5 files).

After which, all was fine and dandy! Now I just need to get my head around how the system works!

Relevant Links:

When is memory leak not a memory leak?

When its a feature of course! There has been a bit of a kerfuffle over a feature in Firefox (1.5) that people are apparently mistaking as the source of a big “memory leak”. The feature in question is the caching of web pages, officially known as the Back-Forward cache. The gist is, the more RAM you have the more pages it caches (up to a limit of eight).

Lead developer Ben Goodger tried to clear the matter up, but looking at the comments he seems to have stirred up a hornets nest. It all sounds very logical and sensible, but the crux of the matter is that Firefox likes its memory.

I agree with the people commenting, I don’t care that this particular feature is memory hungry, the whole program is and its becoming more of an issue. As a developer I can totally see Ben’s point that Firefox is a cross platform, extensible, complex application and as such its to be expected. But part of me wants to ignore the fact I should know better and say “Its a web browser! It displays text and pictures. How can it use so much memory?!”

Am I missing something here? Probably… but its still a valid point.

Make your Comments Stand Out

I was just going through a blog feed for Sun peeps and noticed an interesting post titled Make Your Comments Count! by Tor Norbye. His point was that modern IDE’s tend to hide comments and make the code the most important thing on screen, which is very true. However he noticed a colleague had changed it so his comments stood out, the reason being, he said, is because they’re vital.

I totally agree, comments are incredibly important, but I would have thought that was obvious? For years I’ve used a Delphi colour setting of Twilight which is a black background with white / cyan text. By default comments are in (dark) green which don’t stand out, so I change them to lime green so I can’t miss them then! A chap at work has similar settings to Tor with his comments in red (but with a grey instead of white background).


Not a particularly good example, but it shows how I highlight comments

I used to work with someone who said he didn’t need comments because he wrote “Self Documenting Code” (SDC). If by that he meant incomprehensible crap then full marks! Thing is, there is no such thing as SDC. Comments should be liberally sprinkled about and, this is the key point, be relevant.

If you going back into something (and you will) the comments help to get you up to speed. It is much quicker to read plain English than to decipher the code. Obviously you can determine what the code is doing, but that heads up in the comments is a real help.

I suppose the reason why Mr. SDC never commented is code was because he only every tended to work on stuff he’d written and when he was happy with it, “ownership” would be given to someone else (muggins and others) who would then have to fix any bugs in it (and put comments in)!

Citrix / NFuse fun continued – IIS 6.0

Carrying on from my previous post, I’d mentioned that IIS gave the sites a unique name along the lines of W3SVCn, well it turns out this is called a Site Identification Number (Site ID for short).

So I had an existing installation of NFuse on a machine running IIS 6.0 this time, that was again in the wrong location for what I needed it for (this was the original machine I mentioned previously, I’m using it as a test for setting up https access, but we needed to keep the system live for our customers, hence the messing about).

I tried my old trick of deleting the default site (the one assigned W3SVC1) and creating it again, but was confused because it now had a Site ID of W3SVC3490234 (example). I tried the NFuse installer but was politely told the same as before, “IIS is not installed or is configured incorrectly. Installation of the Web Interface for MetaFrame XP cannot continue.”.

It turns out that in IIS 6.0 the default naming convention is different. It now comes up with a unique ID based on the Site Name in IIS. Great! IIS 5.0 however, used an incrementing number. All was not lost though, by whacking in a registry entry I got it to revert back to the old IIS 5.0 way of working.

To do that, run RegEdit and do the following:

You edit the registry at your own risk, I am not liable for any damage caused, it may explode in flames, blah, blah etc etc.

  1. Expand HKEY_LOCAL_MACHINE, expand SOFTWARE, expand Microsoft, expand the InetMGR subkey, and then click Parameters.
  2. Under Parameters, in the details pane, click IncrementalSiteIDCreation. If the entry does not exist, create it by doing the following:
  3. Select Parameters by clicking on it.
  4. On the Edit Menu, point to New, and then click DWORD Value.
  5. Type IncrementalSiteIDCreation and press ENTER to create the entry.
  6. With the entry IncrementalSiteIDCreation selected, on the Edit menu, click Modify.
  7. In the Value data box, type 1 to force IIS to use the incremental method of generating Web site identification numbers, and then click OK.

I was then able to delete the site again and recreate it with the correct Site ID of W3SVC1. The NFuse installer was then happy and got on with its job. 

Relevant links:

I did try originally to just copy / move the NFuse site manually but the Installer sets up a few virtual folders and various different folder level permissions that are a pain to duplicate!

The joys of Citrix – Problems Installing NFuse

This is going to be quite a boring techie sort of post about Citrix, but I reckon its useful since I can’t find anything related to this on the interweb and I spent a fun afternoon last Saturday working this out.

First things first… Citrix Metaframe is to quote Wikipedia “a remote access/application publishing product”. NFuse is a web front end for Metaframe to allow users to run apps over the web. Simple as that.

For various reasons we were after shifting our NFuse installation onto another machine since the existing one was needed for something else. We’re using MetaFrame XPe (could be XPs) 1.8 Feature Release 3 and NFuse Classic. I’m unsure as to NFuse version number. NFuse was to be installed on a Windows 2000 Server Web Edition box with IIS 5.0.

Ok, down to business. Upon trying to install NFuse it was coming up with a particularly odd location to install to. As it happens it was where MPQArchive was set to. For obvious reasons I didn’t want it installing there but to one of our work websites.


In IIS I changed it so that its default “web site” pointed at the one I wanted. I re-ran the installer and it came up with the same path. So I deleted the site from IIS.

I re-ran the installer again and go this error message:


IIS is not installed or is configured incorrectly. Installation of the Web Interface for MetaFrame XP cannot continue.” Yes it is, its running websites right now! It was at this point, and I don’t know why, a light came on (probably related to me setting up AWStats on IIS logs but anyway). IIS has a habit of using an internal naming convention of W3SVCn (where n is a number) for sites. As far as I’m aware this is just used for log file output, however it would appear the NFuse installer uses it…

I checked all the other sites for what their W3SVCn number was and found that W3SVC1 was missing. I’m not aware of a quick way of checking this and tended to use this method. In IIS select the site, right click it, select “Properties…” from the popup. On the “Properties” dialog, go to the “Web Site” tab and click the “Properties…” button in the lower right hand corner of the screen.


Then at the bottom of the following screen you can see the log file name / site notation.


So I created a new site pointed at where I wanted it to go (basically a duplicate of an existing site). I noted that it was called W3SVC1. It would appear that IIS reuses the names.

I ran the installer again and it ran perfectly. It created the NFuse gubbins where I wanted it and I could then go about the usual NFuse configuration (pointing NFuse at Metaframe). After the install I was able to remove the “duplicate” site in IIS. Note though that if you want to remove / uninstall NFuse you’ll need to put that site back again.

Now I could be completely off base with this, but it seems fairly logical to me!

The following links were of some use, although I am dismayed that a majority said reinstall IIS! Hardly practical is it? We have sites running! Same as the logic of “Oh, just run NFuse on its own server”. Yes, well I’m sure in a world of infinite money and rack space a server for every single iddy bitty little task is just super, smashing, great, but in a small company you have to work with what you’ve got and be resourceful! Maybe that’s why this isn’t such a common error since its usually run on fresh servers? Sigh…

Links (from Citrix Knowledge Base):

The joys of Citrix!

O’Reilly Network Safari Bookshelf

Just over a couple of weeks ago I was in the thick of writing reams of PHP code for my group website & design project. I was searching the interweb looking for PHP security guides (I know has a ton of stuff there, but I was after something specific) and stumbled across a website for an O’Reilly book, Essential PHP Security.

As it happens the two chapters I needed were downloadable (as PDF’s), but after finishing those I wanted to read more of it. I thought surely there would be an e-book version of it? I tried the “Buy Now” option and ended up on Amazon America where I have no intention of buying off. So I went to the O’Reilly website and after much messing about I ended up at the Safari Bookshelf.

It works like a library where you can have so many books a month depending on your subscription level. A 14 day trial was available so I signed up on that. I picked the book I was after… and found out I could read all of it online but needed “download tokens” to get the individual chapters as PDF’s. On the trial you get 1 as a gift but you can’t buy any more. Bugger!

Anyway I found the service very useful. I was able to search all of their books, but in order to properly read them I needed to add them to my “bookshelf”. You can look at a book beforehand but you can only see the first few lines of a chapter. You get so many slots on your bookshelf and depending on the size of a book, it may take up more than 1 slot. Also worth noting is that its not just O’Reilly books you have access to, but books from other publishers such as Addison Wesley, Microsoft Press, Sams and Que to name a few.

My 14 day trial finished last weekend and I err… well I was in two minds about signing up. My mind was made up for me though because I didn’t cancel it, so I’m subscribed monthly at $20 (ex VAT) which allows me 10 bookshelf slots, 5 download tokens and 30 to 35% off the print version of any book. Since I’m doing some Citrix work at the moment, I’ve decided to keep subscribed, since there’s a ton of useful stuff.

But I do have a few gripes. I don’t like the font used for the books content, petty I know, but its Times New Roman which is just an unreadable, horrible, mess of a font. You can increase the size of it but its not good enough. Its just not nice to look at (but with a bit of Web Developer Extension and Greasemonkey tweaking I’m sure I can sort that out :D).

Second to that is how many download tokens its costs to download a book chapter. The logic for it doesn’t add up. I currently have a Citrix book on my bookshelf which takes up 2 slots. The book has well over 20 chapters and it seems each chapter costs 3 download tokens!? With the subscription level I have I get 5 tokens automatically, but to download the book I would need 60+ tokens. A pack of 5 tokens costs $10 which means to buy enough to download the book would cost $120. The book retails for $55! And since I’m now subscribed, I can get a 35% discount so its only $35ish. Ouch. Apparently thats a worst case though…

Finally, whatever method is used to check you’re logged in (cookies me thinks) can be a bit flaky. There have been a few occasions where I’ve closed Firefox, brought it back up and it thinks I’m logged in but doesn’t know who I am! Logging in again fixes that.

All said and done though, I think its a very useful service. I think the pricing could do with lowering but one way to think of it, is like this: If you’re happy to just read online then $20 for 10 books for a month is a bit cheaper than buying them all!

Note 1: I should mention that the majority of the Essential PHP Security book is also available as an Apache Conference paper. Of course I didn’t find that out until afterwards!

Note 2: I also found out that the author, Chris Shiflett, has an excellent PHP Security blog, so that got added into my many, many feeds in FeedDemon.