Thursday, October 8, 2009

Comic - Your Demographic


Happy Thursday Comic - Your Demographic

  ▣


Click here to see Thursday-only posts.


Wednesday, October 7, 2009

Green Porno Educational Video


Green Porno TV Show
The title is ... ummm ... well, it speaks for itself. Green Porno sounds like an environmentalist's fantasy, and in a way it is, when it comes to Isabella Rossellini's Green Porno series for the Sundance Channel. The series explores reproductive habits of non-human species through educational and entertaining short films.

Season 3 just debuted last month on September 14th; and like its predecessors, it's just as hilarious and informative. The relatively new series is focusing on the reproductive habits of sea creatures, and in addition to the amazing puppetry of the previous episodes, will also mix in documentary footage and animation. I’m especially excited to hear that this time around there will be an even more of an environmental spin and will help educate viewers on the impact of some of our eating habits.

Here's a sample from YouTube to help put this show's efforts & intentions into perspective. Enjoy yet another Weird Wednesday must-see video.

Link: http://www.youtube.com/watch?v=T-V621BxHZQ
  ▣


Click here to see Wednesday-only posts.


Tuesday, October 6, 2009

A Simple Firefox 3 Hack to Fix Its Memory Leak


Firefox Logo
Firefox is likely the best browser out there. And in my humble opinion, it pretty much is. But that does not mean that it doesn't have its own share of issues. A quick search reveals how the open source browser is plagued with memory leak issues. Now, Firefox 2 may have been inundated with such memory issues, but the latest and greatest (FF 3.5.x) has resolved many of those issues.

Per Mozilla:
With a new management function in place, Firefox keeps memory usage under control. The XPCOM cycle collector continuously cleans up unused memory. Plus, hundreds of memory leaks have been remedied.


Of course, since Firefox is very extensible (with wide array of extensions, plug-ins, add-ons, etc.), it comes as no surprise that the application would run heavy at times. For most users, Firefox doesn't use an abnormally large amount of memory. For others, however, Firefox's memory consumption is a major problem.

There are many different memory problems, and ways to "patch" them helping you restore some of that much needed memory.

First, though, let's make sure we're all on the same page and define what are memory leaks. Whatis.com defines it as:
A memory leak is the gradual loss of available computer memory when a program (an application or part of the operating system) repeatedly fails to return memory that it has obtained for temporary use. As a result, the available memory for that application or that part of the operating system becomes exhausted and the program can no longer function. For a program that is frequently opened or called or that runs continuously, even a very small memory leak can eventually cause the program or the system to terminate. A memory leak is the result of a program bug.

Some operating systems provide memory leak detection so that a problem can be detected before an application or the operating system crashes. Some program development tools also provide automatic "housekeeping" for the developer. It is always the best programming practice to return memory and any temporary file to the operating system after the program no longer needs it.

Firefox Memory Leak


How do you know how much memory Firefox (or any other application) is specifically using?


Hit Ctrl+Alt+Delete in Windows 2000/XP (or Ctrl+Shift+Esc in Vista/Windows 7) to pop up the built-in Task Manager, which offers a pretty decent look at what programs you're running, as well as current CPU and memory usage for each and a basic description. I personally go straight to the "Processes" tab, and then click on "Image Name" to sort that column alphabetically. I scroll down to the F's and there's firefox.exe. The "Mem Usage" column, matching it to the row of the application you're seeking (Firefox in this case), shows you exactly how much memory that application is consuming in Kilobytes (KBs). If the number is in the thousands, as it will likely be, then simply divide it by 1,024 to know how much it's consuming in megabytes (MBs).

Understanding the columns in Vista/Window 7 can be confusing, so I urge you read "What do the Task Manager memory columns mean?" by Microsoft. How to optimize your system's memory, optimizing the task manager along with a few other tricks along the same line is the subject, I'm hoping, of a future Tip Tuesday on ahmadism.com

Getting back to the browser itself, it's worth mentioning that Firefox caches objects for future use. In addition, memory becomes fragmented as memory is repeatedly allocated and de-allocated. This general increase is normal.

Normal Firefox memory usage reported by Windows might be as high as 100-150 MBs. These numbers will vary because Firefox is configured by default to use more memory on systems that have more memory available and less on systems with less. If you experience substantially more usage than this, there may be a problem, or you may just be viewing pages with large amounts of data.

So could Firefox extensions, themes and plug-ins be causing this?


For extensions & themes (not plug-ins), observing memory usage while Firefox is in safe mode may help tell you whether one of your extensions or themes is causing memory problems. There is a list of extension-specific problems, which may be of benefit.

Firefox Addons
Plugins can cause Firefox to use more memory when they're used and may not release their memory until Firefox is closed. It's a good idea to make sure you're using the most recent version of every plugin. To save the maximum amount of memory, uninstall any unnecessary plugins. Or you can block/control specific instances of memory usage, such as for Flash Player, via extensions or configuration options. Flash images in particular are pervasive in modern web pages (as ads, videos, etc) and so are a common source of memory usage. Here's some plugin-specific information.

Reducing Adobe Reader memory usage

Aside from extensions, themes and plug-ins, what else could be consuming memory when using Firefox?


In addition to the settings you can make/modify to reduce memory usage (below), there's download history.
Memory usage can increase and Firefox can slow down or hang if the download history is allowed to accumulate. Clear the download history (you may need to exit Firefox and delete the file "downloads.rdf" from the profile folder in some very rare cases) and change this setting to circumvent the problem:

"Tools -> Options -> Privacy -> Download History -> Remove Files from the Download Manager", select: "Upon successful download".

So what settings can you change to reduce Firefox's memory usage?


Aaah, the trade secrets at last. Before I move on, it is essential that you understand that many (if not all) the changes suggested below require a change to the browser's configuration; which is like messing with Windows' registry and could render your browser useless in the worst case scenario. Changing the about:config preferences below may have an effect on memory consumption but may also affect performance or reduce functionality. Use at your own risk.

How to access the about:config preferences in Firefox 3


In Firefox, type about:config in the Location Bar (address bar) and press Enter to access the hidden configuration options and display the list of preferences, as shown below in Firefox 3. (If you see a page with the warning message, This might void your warranty!, click the button labeled "I'll be careful, I promise!", to continue.)

Firefox about:config


Firefox Config
To add a new preference, context-click (right-click) anywhere in the list of preferences. In the context menu, select New then select the type of preference you are adding.
  • String is any sequence of text
  • Integer is a number
  • Boolean is true-false

To modify an existing preference, context-click (right-click) on the preference, select Modify and type in the new value. In some cases, Toggle will be the selection offered for boolean (true-false) preferences.

To reset a preference to its default value or to remove an added preference, context-click (right-click) on the preference and select Reset. If you added the entry via about:config, the preference will no longer be listed after restarting the program.

browser.cache.memory.capacity


Controls how much memory is used to cache pages. More accurately (and geeky), when images are loaded, they can be cached so they don't need to be decoded or uncompressed to be redisplayed. This preference controls the maximum amount of memory to use for caching decoded images and chrome (application user interface elements).

Right click on the page and choose New then Integer and create an integer called browser.cache.memory.capacity and set it to a low number. This controls how many kilobytes of memory are used for the browser’s cache.

The possible value of "-1" (without the quotes) means Firefox will automatically decide the maximum memory to use to cache decoded images and chrome based on the total amount of RAM.

"0" (the number zero, again without the quotes) means do not cache decoded images and chrome in memory. Any positive integer means the maximum amount of memory in KB to use to cache decoded images and chrome (1 MBs = 1024 KBs).

Caveats: browser.cache.memory.enable (see below) must be true for this preference to take effect. Lowering this value causes less memory to be used but also increases the load time of previously visited pages and dialogs. Raising it has the opposite effect.
To view current memory cache usage, put about:cache?device=memory in the Location Bar
This preference does not exist by default in applications other than Thunderbird.

What numbers do I recommend? Well, if you have 1 GBs of RAM installed in your machine, then try 32768 KBs as the memory cache integer. For 2 GBs, try 45056 KBs. And for 4 GBs, try 59392. If you have more than 4 GBs then you shouldn't be complaining about memory leaks ;)

browser.cache.memory.enable


This boolean preference (true or false) looks at when a page is loaded, it can be cached so it doesn't need to be rerendered to be redisplayed. This preference controls whether to use memory to cache decoded images, chrome (application user interface elements), and secure (https) pages. browser.cache.memory.capacity (above) controls the maximum amount of memory to use.

A value of "true" (without the quotes), which is the default value in Firefox, allows decoded images, chrome, and secure pages to be cached in memory. Whereas a value of "false" (without the quotes) means don't cache decoded images, chrome, and secure pages in memory.

Caveats: Setting this preference to false causes less memory to be used but also increases the load time of previously visited pages and dialogs, especially those of secure sites.
If browser.cache.disk_cache_ssl is set to true, secure pages will be stored in disk cache, not memory cache.

browser.sessionhistory.max_total_viewers


Pages that were recently visited are stored in memory in such a way that they don't have to be re-parsed (this is different from the memory cache). This improves performance when pressing Back and Forward.

This preference limits the maximum number of pages stored in memory per tab.

Like browser.cache.memory.capacity, a "-1" (without the quotes) will automatically determine the maximum amount of pages to store in memory based on the total amount of RAM. "-1" is the default value. "0" (the number zero without quotes) tells Firefox to not store any pages in memory. Whereas any positive integer up to 8 will indicate the number of pages to store in memory.

Lowering this value causes less memory to be used but also causes more previously visited pages to have to be re-parsed (thus increasing their load time). Raising it has the opposite effect. One page will on average take 4MB of memory. I personally recommend the value to be between 5 and 8, but if need be, it can go down to 2 or even 1.

config.trim_on_minimize


Configure Firefox (Windows only) to swap memory to disk when minimized. This will make Firefox less responsive if you minimize/maximize a lot, but it is good if you need to free memory while multi-tasking to other applications.

Firefox Config Preferences

Right click on the page and choose New then Boolean and create a boolean called config.trim_on_minimize and set it to true. Now when you minimize the window it will free up memory.

network.prefetch-next


Network link prefetch will download all pages with the rel=”prefetch” tag. This uses up more memory than you would otherwise think. Simply set network.prefetch-next to false. However, for sites that use prefetching, disabling this preference will decrease the amount of bandwidth used, but increase the time required to navigate sites.

Firefox Config Preference Change


browser.cache.disk.capacity


When a page is loaded, it is cached so it doesn't need to be downloaded to be redisplayed. This preference controls the maximum amount of hard drive space to use for caching purposes. A positive integer means a maximum amount of hard drive space in KB to use for cache. Firefox's default is 50000 KBs. A value of "0" (the number zero without any quotes) means do not cache files on the hard drive. Note: browser.cache.disk.enable must be true for this preference to take effect.

Firefox Config Preferences

I know it must be odd that I'm even suggesting this, but an there are extensions out there that could help. Amongst such extensions is RAMBack, which allows the user to manually free memory, such as caches, that is usually used to increase performance. This gives the advantage of small cache sizes without having to always suffer the performance hit.

And finally the obvious ... If you find that Firefox's memory usage continues to grow after long periods of being open, you may want to consider periodically restarting Firefox to bring the memory usage back to reasonable levels. Close Firefox and select the Save and Quit option to reopen your tabs when Firefox restarts.

I'm curious how all of this helps. Share it with the rest of us in the comments.  ▣


Click here to see Tuesday-only posts.


Monday, October 5, 2009

The Winds of Change


William Kamkwamba (born 1987) is a Malawian innovator who gained fame in his country when, in 2001, he self-built a windmill to power one reading light bulb in his family's house in Masitala, a tiny rural farming village off the grid in Malawi - at the age of 14.

William Kamkwamba Windmill


Naturally, he had to build more; two more, in fact. All three powered at least four light bulbs, a couple of radios, reports of a TV and even charge some of the villagers' cell phones.

Per Wikipedia:
When the Daily Times newspaper in Blantyre wrote a story on Kamkwamba's windmills in November 2006, the story circulated through the blogosphere, and TED conference director Emeka Okafor (TED) invited Kamkwamba to speak at TED Global 2007 in Arusha, Tanzania as a guest. His speech moved the audience, and several venture capitalists at the conference pledged to help finance his secondary education. His story was covered by Sarah Childress for the Wall Street Journal. He became a student at African Bible College Christian Academy in Lilongwe, but is now on a scholarship at the African Leadership Academy in Johannesburg, South Africa.


Here's the first TED conference in Tanzania (2007), which shows just how nervous Kamkwamba was; followed by the second TED conference in the UK where Kamkwamba is now more confident with aspirations to take his dreams even farther.


Link: http://www.youtube.com/watch?v=G8yKFVPOD6o


Link: http://www.youtube.com/watch?v=crjU5hu2fag

Wired has very good coverage of the story, the materials he scrounged from neighboring dumpyards, some of the hardship, etc.

Here's a short film, Moving Windmills, which should come as no surprise that it (and this whole inspirational story) is being made into a feature-length documentary.


Link: http://www.youtube.com/watch?v=arD374MFk4w

His story is given in The Boy Who Harnessed the Wind, written by himself and Bryan Mealer, published in 2009 (ISBN 9780061730320). Kamkwamba took part in the first event celebrating his particular type of ingenuity, called Maker Faire Africa, which took place in Ghana in August 2009.  ▣


Click here to see Monday-only posts.