Monday, August 23, 2010

On managing memory leakage with assignment to IMG src in UIWebView

The issue with leaking memory due to dynamic image updates in 
UIWebView hosted pages can be fixed with a solution I call

The "humpty dumpty" solution !

The problem can be particularly severe on the 128MB iPhone 3G
for long running charting applications.

To summarize, the statement for any IMG being dynamically updated is -

img.src = url; // this url is a dynamic image file generator

Now most browsers will not retrieve the url more than twice ( why twice
I do not know, it is repeatable on the current versions of Safari and Chrome ).

So we add something to force the browser to call the URL -

img.src = url + ?now // seconds since epoch will do
img.src = url + ?incarnation++ // a incrementing incarnation


Now webkit starts leaking memory by storing all the urls
that are thus generated, in the charting application I am issuing
these as rapidly as once a second.

So now lets just simplify this to

if img.src contains 'humpty'
img.src = url + ?incarnation=dumpty
else
img.src = url + ?incarnation=humpty


!!!

This should resolve the issue with storing a new URL every second,
but it does not work. This is because webkit ( and any browser )
will simply go to cache for humpty and dumpty after the first
2 origin server fetches.

To fix this, add HTTP headers to the response from the image handler URL -

Expires: 0
Pragma: no-cache
Cache-Control: no-store, no-cache, must-revalidate


This is the minimal set which is supposed to work across all the different
proxy servers which may lie on the path, though if there is no
proxy server just

Cache-control: no-store

will work fine with webkit.

Tuesday, April 13, 2010

On Windows hosts file not working

The hosts file ( C:\windows\system32\drivers\etc\hosts ) is used by TCP/IP
before it tries to resolve a name from a DNS server. But sometimes, it stops
working for some unfathomable reason.

First, make sure DatabasePath in your registry under TCPIP/Parameters
is correctly pointing to C:\WINDOWS\System32\drivers\etc.

But I recently ran into a problem where everything was apparently
fine but Windows could not resolve any entry in the hosts file.

Fiddling around with DNS Client ( dnscache ) and ipconfig /flushdns
did not help.

I finally got hold of the solution which I will post here for people who
may otherwise have to waste days. Follow the instructions here -

Monday, October 6, 2008

On installing IIS on Windows XP without the original XP cd

I had a need to install IIS when my Windows XP cd was sitting with someone else who was away on vacation. It was quite urgent. This is not an easy thing to do and I finally solved the problem using a torrent download of the integrated Windows XP with SP3 ISO file ( my first torrent download ) and Microsoft's unsupported ISO mount utility called VCDROM.SYS.

You need to go through this entire process. When IIS starts complaining about missing files, do not download them one at a time from sites like dll-files.com.
Firstly, you will have to download plenty of files one at a time because you dont know which one IIS will ask for next. Second, once it starts asking for wierd files like infoctrs.h2, you will be out of luck.

Thus you need to download the Windows XP CD ( not the Service Pack cd because they do not contain ALL the files ). There is a integrated Windows XP+SP3 ISO file which can be downloaded by torrent. If torrents are new to you, so they were to me yesterday. It is easy.

Here is the torrent url - if you cannot find a peer email me and I will gladly host it for you.

http://torrents.calcuttatraders.com/Windows_XP_Professional_with_Service_Pack_3_(x86)_Retail.4169906.TPB

I am assuming you have uTorrent or something similar. If not, google it and
download it. Install the software and load the torrent file mentioned above. Start the download. This is the tricky part. I am new to torrents but it seems your luck depends on extraneous factors on which you have little control.

Anyway, my download completed in 5 hours. uTorrent saves the downloaded ISO file in the Downloads subfolder of My Documents.

Now you have to mount the ISO file. Download VCDROM from the following link -

http://download.microsoft.com/download/7/b/6/7b6abd84-7841-4978-96f5-bd58df02efa2/winxpvirtualcdcontrolpanel_21.exe

Follow the instructions in the README file. Once you are done, you should have a new drive on your machine ( eg. Z: ) where you have all the files needed by the IIS installation under the subfolder i386/.

Monday, May 5, 2008

On problems with grabbing audio from your desktop

Following up on my previous post about the Freecorder
toolbar. I thought is had stopped working for me after
a couple of days. Then I realized the mistake that I
was making, and which many people will make. The
problem is that you must press the Record button
before starting the audio.

So if you, say, start a radio station, and while it
is playing you want to capture something, it will not
work. You must have the freecorder already in record
mode. Stop the radio station, start freecorder recording
and then restart the station.

Monday, April 28, 2008

On grabbing audio from your desktop

This is something which is very useful. Often you have a stream of audio playing on your machine, maybe a radio station or from some website, which you want to capture. It is easy to do this using a very useful free toolbar program called Freecorder. Freecorder is completely free and captures everything going through your sound card. You can subsequently edit the captured audio using another great free product, Wavepad, which has numerous options for editing and modifying audio.

Saturday, April 26, 2008

On recovering files from your non-booting Windows machine

Lets face it, the problem above is a very common one.

You have a machine that is your life and soul, as mine
is. Suddenly one morning it refuses to boot. One of
the most common reasons for this is a corruption of
the Windows registry, the most heavily accessed part
of your file system.

How do you recover the many files and other settings
like your favorites? The various options of Windows
itself, like recovery mode, will not work. Not unless
you are some kind of bit-level genius with metal-level
knowledge of ethernet and usb.

There is something called Knoppix, a Linux which
runs from cd. I have tried it and it is very very
difficult for non-Linux-geeks. Also, the ISO file
which you need to download and burn to create the
Knoppix system is a pain. It gets corrupted, and
whether your boot cd will work or not is a toss-up.

Welcome to the great Bart! This gent has been in
the business of creating boot freeware from the
DOS days. But now he has come up with arguably a
masterpiece - Bart's Preinstalled Environment (BartPE)
bootable live windows CD/DVD.

I will not delve into this at great length. Suffice
to say that normal humans can do this very easily
by spending about 10 minutes reading his instructions.
You will soon be able to boot your machine, and it
will come up with a familiar Windows graphical
environment with USB and net support. Just copy those
files off to wherever or whatever you want and say
thanks to Bart!

On the Nokia CA-42 data cable - II

Apropos the previous post, it is necessary to know
what to do if you have been messing around with the
knock-off cables and your system is now so screwed
up that following the steps laid out therein will
not work.

Ground zero. Uninstall Nokia PC Suite. Go into
Add/Remove Programs in Control Panel, and remove
PC connection software and CA-42 Connectivity Cable
driver. Uninstalling Nokia PC Suite does not get
rid of these two.

Then, if you have XP, do system restore to a date
well in the past, before you bought that cursed
knock-off cable. If you have some other OS, re-install it!

Once this is done, and after your machine reboots,
follow the steps for installing the genuine thing
as outlined in the previous post.

Now, if it still doesnt work, go into Nokia
Connection Manager from Control Panel and check
the settings for Serial Cable. It should point
to the correct COM port, the one on which the
newly installed Nokia CA-42 GSM USB modem has
been set. You may need to do trial and error here.

Thats about it. If you do not have a entry for
Nokia CA-42 USB GSM modem in your list of network
connectors, you are in deep doo-doo. Start from
scratch.