Archive for December, 2007
Paul is an Eagle!
My oldest son, Paul, had his Board of Review last night, and is now an Eagle Scout. I am so proud of him, obviously.
After the board was finished with their deliberations, they took a moment for each member to share some of their observations about Paul. And his mom and I were invited in to hear these. The board was several adults, most of whom did not know each other, but all knew Paul from various places - school, church, scouting. It was great to hear all the positive observations they shared about Paul. And equally great to hear a consensus that he is the same kind of person in all these different environments.
The comments last night made it clear what we already knew about Paul: while he did work hard to meet all the Eagle requirements, he did not have to work to become the kind of person you expect an Eagle to be. He just is that kind of person.
He worked hard for this, obviously, but all that work served only to validate who he already was.
Congratulations, Paul!
CSS Overflow Scrollbars and IE
Someone pointed out to me that some of my code sections were unreadable in Internet Explorer. They looked like this:

Hey! where’s the text? The rest of us (at least Firefox and Safari) were seeing something more like this:

Much better, but what’s going on?
I quote code in a <pre class="code">....</pre> block. And my style sheet contained:
.code {
font-family: courier, monospace;
margin: 10px 20px;
padding: 3px 8px;
border: 1px dashed #999999;
overflow:auto;
}
It looked to me like IE was robbing space from either the text height or the padding to cram in a scrollbar. And since that made the resulting area for text too small, it also added a (way too small) vertical scrollbar, too. The result is non-functional in any real sense.
A bit of searching and I am drawn to this comment from the CSS 2.1 spec:
In the case of a scrollbar being placed on an edge of the element’s box, it should be inserted between the inner border edge and the outer padding edge. Any space taken up by the scrollbars should be subtracted from the computed width/height, thus preserving the inner border edge.
As I read this, the scrollbar needs to fit inside the element border, and thus subtracts from space that can be used for the content. This does preserve the overall size of the element no matter what type of scrolling might be used (or not). But in my context, it seems wrong. It also means that IE is probably right here (which also goes against my intuition :).
Wrong or not, it is certainly not what I want. So I did more hunting and experimenting, and I found only two solutions that I really thought worked.
First, I could simply increase the padding-bottom to make room for the scrollbar. This solution is nice because it keeps the browser-specific hacks out of the stylesheet. But I don’t like the way this looks when there is not a scrollbar, because there’s extra blank padding at the bottom.
So the only real choice for me was to add some browser-specific thing to the stylesheet. What I ended up with is based mainly on
this post, and looks like this:
.code {
font-family: courier, monospace;
margin: 10px 20px;
padding: 3px 8px;
border: 1px dashed #999999;
overflow:auto;
/* add padding in IE (which supports expressions) to make room for the scroll bar */
padding-bottom: expression(this.scrollWidth > this.offsetWidth ? "19px" : "3px");
}
This seems to be working reasonably well, as it does not mangle the size of the element when there is no need for a scrollbar, and it bumps up the bottom padding to make way for IE’s scrollbar.
There are some downsides, like the expression is probably being over-evaluated, and it relies on a proprietary IE feature (expressions), so I may reevaluate this in the future. But for now at least my blog is (more) readable for IE users.
Technorati Tags: css, ie, scrollbar
No commentsTime Machine Woes

Yesterday, I decided it was time to move on. I deleted my bootable Tiger backup and turned on Time Machine. I like the fact that it promises to do hourly/daily/weekly incremental backups, and the Time Machine application, while heavy on the cheese, is a pretty nice way to access backup recovery.
But backups aren’t backups unless you test that you can recover files (and you know how to do it without having to mess around when the time comes). So today, with a day’s worth of backup history, I decided to play with Time Machine.
I flipped back and forth thru time-cheese, and after a few seconds the world disappeared. Oh wait, it was just my MacBook Pro rebooting. Bong. Apple. Spin wheel. Login.
Nothing in any of the logs (there wasn’t time) - just a hard, fast, shutdown.
So, I did what any self-respecting software engineer would do. I tried it again. Same result. I have now hard-rebooted my machine like 10 times via Time Machine (I don’t recommend it).
If recovering a file risks a hard shutdown, and I can’t resolve this - I will just have to go back to rsync.
Technorati Tags: apple, leopard, mac, reboot, time machine
No commentsLeopard impressions
I’ve had Leopard installed for several days now, and mostly it is good. Here are some delights and gripes and bugs and other thoughts.
Mail still doesn’t obey the Hide checkbox when it is started at login. Just what is so hard about this? I find this really annoying. My son did figure out a rather clever “cheat” - he starts Mail in a different Space, so it is not really hidden, but just looks that way (but I’m not using Spaces).
And Mail still doesn’t grok the age-old function “go to next unread message” (the shortcut for this should be “spacebar”).
On the plus side, Mail will finally display a proper count of unread messages in the Dock icon (rather than only counting messages in the inbox).
And in the bug arena, there is something seriously wrong. I occasionally see a popup from Mail saying it can’t identify the certificate for pop.gmail.com.
When I inspect the certificate, it is the one for my work email account. So something is seriously broken in Mail’s multiple-account settings or fetching.
Mail / RSS
I never really have got along with RSS in the browser - never seemed right to me. So I thought having it in Mail was a good idea - it’s really where I’ve wanted most of my feeds all along. But Apple’s implementation is just not “there” yet. It would probably work for someone with just a handful of feeds, but not for me.
First, there is just no way to import a set of feeds from anywhere but Safari. I found these instructions and got my OPML feeds imported (via Firefox to Safari to Mail - ugh), but they lost their folders. It took me a while to figure out that you can create folders for feeds (you just create a new mailbox), and then I was on the way to rebuilding my folders, and importing feeds into them. But along the way I figured out that you can’t sort or arrange anything. So I was stuck thinking I’d have to rename my folders so they’d be “aNews”, “bTech”, “cBlogs”, etc. Gack. And things were just getting crowded in the sidebar - what with my inboxes and all my mail folders, there just wasn’t room for a dozen more folders for feeds.
So I came to my senses and went back to using the most excellent NetNewsWire.
Safari
I think the best thing in the new Safari is actually the new eye candy in the Find feature. I was always having trouble seeing the default (subtile) blue highlight. Apple has now made it easy to see the find results on any web page (regardless of color scheme).
The history menu also now has two new options: Reopen Last Closed Window and Reopen All Windows from Last Session. Fantastic for those of us who sometimes accidentally close or quit.
The other two things I like come with the debug menu. First, they moved Open Page With and User Agent from the bottom to the top of the menu. And the new Web Inspector is great (kinda like Firebug, but more Apple-y). I especially like the way it rolls up CSS styles and shows Metrics (margins/borders/padding/size).
Spotlight
Spotlight just seems to work better. First, there’s new stuff contributing - most notibly Web History. Spotlight searches now include your Safari cache, so you can find that site you visited last week.
Also, they’ve made the “Top Hit” automatically selected (rather than messing around with the Command key). I can type, for example, C-Space, sys, Return and get System Preferences. It’s just better.
iCal
Well, finally you can set a default alarm for new events, although there’s no way that I can see to set the default sound to anything but Basso. And the default alarm doesn’t seem to apply to notifications created from Mail. So some progress here, but still a way to go.
Stacks
I actually like this. I used to keep folders in my Dock for Applications and Downloads, but this just works better. I don’t really like the Fan view, but since my Dock is on the side, all I and use is Grid anyway.
Quick Look
This is going to be really handy, especially now that I’m starting to learn the shortcut (Command-Y). It’s way faster than launching an app just to see what’s in the file. Next, I’m going to have to try a code syntax highlighter.
Random Issues
I have my desktop background set to display photos from a folder. Sometimes, first thing in the morning, my second monitor comes up with the default Leopard background. If I bring up preferences, it does think that it’s displaying the photos. If I wait a half-hour (when the photo is scheduled to change), it gets with the program.
I have noticed that the login dialog doesn’t get focus when I wake from sleep. So I type my password and nothing happens till I click in the login dialog. The worst part is that I sometimes have found bits (or all) of my password sitting in other dialogs or documents - which means those dialogs actually had keyboard focus while they were supposed to be locked out. Scary.
I am disappointed that WiFi with WPA is still not right. I have never been able to hold a connection to our work WAN for more than about 15 minutes (it had steadily grown from 5 to about 15 over several Tiger updates). Now, it seems we’re back to 5 minutes. My home network (Linksys) is not as bad as at work, but it does drop connections occasionally, too. I have no data, but it does seem worse than with the last update of Tiger. I never had these problems with my PowerBook.
Technorati Tags: apple, leopard, mac
No commentsLeak Testing
So, here we are. We have found lots of memory leaks, and drastically improved the redeploy experience for WLP 10.2 (and the fixes are being backported to previous releases).
However, this is not the first time we’ve been here. But it is hopefully the last.
We are putting in place a test environment to keep these leaks plugged. Actually, to be more precise, we’re adding some instrumentation to our integration test suite that drives tests via the IDE. So this test will behave just like a developer - although it’s a rather anti-social and uninteresting developer :).
Note that this technique is not restricted to WLP or redeployment testing, but hopefully you can find it useful for other situations.
Counting ClassLoader Instances
The basis of this technique is that we know that the leaks we are interested in happen to always hold on to the application or webapp ClassLoader. Further, we also know that these ClassLoaders are instances of GenericClassLoader (for the app) or ChangeAwareClassLoader (for the webapp).
So, our instrumentation relies on being able to count the instances of these classes. Fortunately, JRockit can do this easily, without any extra messing about with the startup settings or whatnot.
JRockit comes with this handy jrcmd command. It lets you interact with a running JRockit JVM, like for example the WLS server. You can use it to do all sorts of interesting things:
- find out the JVM’s command line (how it was started)
- print thread dumps
- change the verbosity of the JVM on the fly (things like garbage collector stats)
- trigger a garbage collection
- print a GC report
- print diagnostics about memory usage
All sorts of cool things - and none of these require you to change anything about your running process. No command line switches or anything messy like that.
So, we are looking for a count of the instances of our ClassLoader objects. We do that by running:
jrcmd <wls server pid> heap_diagnostics
(You get the wls server pid by running just jrcmd - it will print the process ids of running JRockit instances.)
If you run that, you’ll see tons and tons of output - including a listing of every class loaded by the system and how many instances there are. So all we need to do is search for the class we are interested in:
jrcmd <wls server pid> heap_diagnostics | grep '%.*GenericClassLoader
That will grep for the one line we are interested in (turns out it contains a percent sign; why is not important here). We’ll get output something like this:
0.0% 10k 150 +10k weblogic/utils/classloaders/GenericClassLoader
In the above, we see that there are 150 instances of the GenericClassLoader.
To get a more accurate count, we also want to trigger a full garbage collection and finalization before counting anything. We can do that with jrcmd also:
jrcmd <wls server pid> runfinalization
Using this information, here’s what we are doing for WLP testing:
- Start the server, with the application undeployed.
- Run finalization and count the GenericClassLoader and ChangeAwareClassLoader instances. This gives us a baseline for the number of instances used by the server itself.
- Deploy the application and use it (i.e. wander through the portal in a browser)
- Count instances again.
- Redeploy the application, use it, and recount.
- Repeat the redeploy step several times.
- Undeploy the application.
- Count instances.
All these counts (and additionally the [re-]deploy times) are all being recorded and analyzed. The most important metric is that the first and last counts are the same - after the application is undeployed, the ClassLoaders used by the application should be gone. We are collecting the intermediate results because we expect they might be useful in failure analysis.
The one last step is that we are running the JVM instrumented for YourKit, and configured to dump a memory snapshot on exit. So if the ClassLoader counts don’t look right, a developer will have the memory snapshot for analysis, without having to rerun the whole test suite.
Hopefully some of this information can be useful if you have leaks you are hunting.
Technorati Tags: JRockit, leak, memory, portal, YourKit, WebLogic
No comments