Archive for February 2009

 
 

Compress your JBoss Portal Theme with pack:tag

from http://www.andypemberton.com/jboss/compress-your-jboss-portal-theme-with-packtag/

The goal of this article is to show you how to use pack:tag to optimize the performance of your JBoss Portal theme. I’ve used this approach on a production JBoss Portal 2.6 implementation and tested the approach out in version 2.7.

JBoss Portal has a feature-rich theme framework where CSS and javascript resources are included in the Portal; building a custom theme is easy. Pack:tag is an open source project that optimizes performance for java-based web apps; it provides a JSP tag library that automatically minifies, compresses, and combines CSS and javascript resources.

As more rich features and dynamic components reach your portal, larger AJAX frameworks and CSS libraries are required to support them. Large downloads will not only make your Portal load slower, but will also take longer to execute when using the Portal. Also, Portals are no longer accessed solely inside the firewall, many companies use them to power external facing sites - so few assumptions should be made about client bandwidth. Compressing your Portal theme with pack:tag will lead to faster downloads and page response time.

Building a custom Portal theme is covered in depth elsewhere, so we won’t get into that here. Instead, let’s look at the steps necessary to get your theme working with pack:tag:

Install pack:tag

  • Place the packtag-X.X.jar in the WEB-INF lib of your theme. To use pack:tag with one of the out of the box themes, place the packtag JAR at: [PS_HOME]/server/default/deploy/jboss-portal.sar/portal-core.war/WEB-INF/lib
  • You’ll also want to place the packtag.properties file in WEB-INF

Pack Your Theme

  • By default, you should have theme resources defined in a *-themes.xml file - because pack:tag uses a tag library, we have to move these resources from the XML file and put them into your layout JSP page.
  • Add the pack:tag tld reference to your layout JSP:
    1. <%@ taglib prefix=“pack” uri=“http://packtag.sf.net” %>
  • Wrap the resource references in the pack:tag; for our custom theme this looks something like:
    1. <pack:style>
    2. <src>/styles/extjs/css/ext-all.css</src>
    3. <src>/styles/extjs/css/xtheme-gray.css</src>
    4. <src>/styles/app.css</src>
    5. </pack:style>
    1. <pack:script>
    2. <src>/scripts/jquery/jquery.js</src>
    3. <src>/scripts/extjs/adapter/jquery/ext-jquery-adapter.js</src>
    4. <src>/scripts/extjs/ext-all-debug.js</src>
    5. </pack:script>

Limitations and Gotchas

  • In JBoss Portal themes, layouts and themes are loosely coupled: layouts are used to generate markup, while themes include CSS and javascript references to style the layout. If you’ve written a JBoss Portal theme before, you’re probably thinking that we just tightly coupled the layout and theme.
  • Well, this is true - but, it turns out that the mechanism that provides the loose coupling has some problems out of the box. For one thing, Portal reorders your script and CSS references in the worst possible way (placing all the links after the scripts). This violates Yahoo’s best practices for website performance.
  • So, we can work around the tight coupling we’ve added by creating an additional JSP include file that will store the css/js references for your custom theme(s). You can then dynamically reference the active theme to load the appropriate theme files. The following snippet will do the trick for JBoss Portal 2.6.X:
    1. <jsp:include page=“includes/theme-${requestScope['RENDERCONTEXT'].themeContext.theme.themeInfo.name}.jsp” />
  • Additionally, introducing pack:tag can also cause unexpected issues with your theme. Because pack:tag combines all your resource requests into a single request (see the first Yahoo performance rule), image references in CSS files can break. So if you get 404s on resource requests after enabling pack:tag, you’ll know what to debug.

Example

Check out the following Firebug screen shots depicting the actual file size savings in our custom theme:

Custom Theme CSS Before pack:tag

Custom Theme CSS Before pack:tag

Custom Theme CSS After pack:tag

Custom Theme CSS After pack:tag

Custom Theme JS Before pack:tag

Custom Theme JS Before pack:tag

Custom Theme JS After pack:tag

Custom Theme JS After pack:tag

Results

That’s right! Adding pack:tag resulted in:

  • Total CSS file size downloaded went from 141KB to 21KB - ~15% the original size
  • 6 HTTP requests for CSS reduced to 2
  • Total javascript file size downloaded went from 2MB to 188KB - ~10% the original size
  • 21 HTTP requests for javascript reduced to 1

References and Tools

5 Tips To Reduce Firefox Memory and Cache Usage

from http://www.davidtan.org/tips-reduce-firefox-memory-cache-usage/

Sometimes I just feel that Firefox is such a memory hog. Once I start to open up a few extra tabs, it starts to slow down my whole system. Fortunately, you can do something about it. Here are simple tips and tricks to reduce firefox memory and cache consumption.

Tip 1: Reduce session history
browser.sessionhistory.max_entries determines the maximum number of pages in the browser’s session history, i.e. the maximum number of URLs you can traverse purely through the Back/Forward buttons. The Default value is 50.
We usually won’t surf more than 5 of the websites we previously surfed before, and there is really no need to store more than that in the session which can clog up memory as they grow.
1. Open Firefox
2. Type about:config in the Firefox address bar
3. Press CTRL-F and search for browser.sessionhistory.max_entries
4. Double click on the value 50 (or whatever value is there currently) and change it to something lower such as 5.
5. Restart Firefox.

For Firefox 1.5 and above, you can also look at another configuration variable browser. sessionhistory. max_total_viewers which also determines the maximum number of content viewers to cache for “bfcache” (fast back/forward navigation). Default value is -1 (calculate based on available memory).
Set it to 0 so that no pages will be stored in memory.
set it to a number such as 5 to store only 5 pages in memory.
more info here

Tip 2: Reduce memory usage when minimize
1. Start up Firefox
2. Type in about:config in the address bar and hit Enter
3. Right click and choose New > Boolean
4. Type config.trim_on_minimize in the pop-up box and hit Enter
5. Select True and hit Enter.
6. Restart Firefox

Tip 3: Fixed cache capacity OR Disable Cache Totally
Every time new page is loaded, Firefox will cache the page so it doesn’t need to load again to be redisplayed. By default, this setting is set to -1 for browser.cache.memory.capacity and to a number you specified in Tools -> Options -> Advanced -> Network / Cache for browser.cache.disk.capacity

To fix your cache to a certain value:
*browser.cache.memory.enable and browser.cache.disk.enable needs to be True for this to work
1. Start up Firefox
2. Type about:config in the address bar and hit Enter
3. Search for browser.cache.memory.capacity and set a number in KB to use for the memory cache (ie. 1024KB = 1MB).
4. Search for browser.cache.disk.capacity and set a number in KB to use for the disk cache (ie. 1024KB = 1MB).

To Disable the cache Totally
Set both browser.cache.memory.capacity and browser.cache.disk.capacity to 0.
Alternatively, you can also set browser.cache.disk.enable and browser.cache.memory.enable to False.

Tip 4: Use less extension and themes
This is really a no brainer. Uninstall all firefox extensions and themes that you don’t use as they can cause Firefox to use more RAM. If you think that you might still need the extension in future but not using it currently, at least there’s an option to Disable it. Use only extensions that you usually use to cut down memory usage.

Always upgrade your extensions and themes to the latest version as they may fix the some problems leading to memory leaks. Firefox makes this quit easy as it now does the checking for you, all you need is to do is tick some checkboxes and your plugins and themes wil be updated.

Tip 5: Check Firefox Memory Usage
Type about:cache?device=memory in the address bar and hit Enter. Firefox will display your current number of entries, maximum storage size, storage in use and inactive storage.

There you have it. Happy browsing!

[notice] child pid 4005 exit signal Segmentation fault (11)

[notice] child pid 4005 exit signal Segmentation fault (11)
If you read this from the httpd log, please check that whether you have the following running at the same time:

  1. Zend Optimizer
  2. apc
  3. eAccelerator

If yes, disable and only leave one running.

Losing Focus after MessageBox::Show

When doing the window form application assignment, just find out that after MessageBox::Show, the window form will lose its focus.

Reason:

Member name Description
ServiceNotification The message box is displayed on the active desktop.
DefaultDesktopOnly The message box is displayed on the active desktop.
RightAlign The message box text is right-aligned.
RtlReading Specifies that the message box text is displayed with right to left reading order.

Because once you use one of the two top options, the focus will move to previous active application.

Solution:

Just simply remove the MessageBoxOptions in MessageBox::Show call.

Reference:

http://msdn.microsoft.com/en-us/library/system.windows.forms.messageboxoptions.aspx

Apply to:

C++/CLI