Flyweight Transformers

One thing had always bugged me about the Transformers in the movies. For some reason they just don’t seem that realistic. Now I know why, after seeing a segment of Tranformers 3 demoed in Best Buy today. It was a fight scene near the end where Sentinal Prime, Megatron and Optimus Prime had their final showdown. In the end Sentinal Prime and Megatron died, Optimus Prime sustained heavy injuries, but the venue, which was a bridge, was more or less intact. Even a sedan crashing into the bridge would have left more damage, so I am sure a heavy duty robot would have left the place in ruins.

Gen 2 Heap GC

For the past two weeks I had been trouble-shooting a resource leak problem.  The data processing job, which works fine for a day worth of data, would bog down after processing 4 or 5 days of data.  Typical symptoms are 100% CPU usage with max RAM consumption.  Connections to the process’s WCF service would time out too.

After some experimentations, I ruled out resource leaks and concluded that the problem is memory usage.  The process builds a humongous dictionary and only releases all objects at the end after 40++ minutes.  This means almost all the objects end up in generation 2 heap at the end, and gen 2 garbage collection is expensive.  My observations from perf counters (GC % time is 99%), connection timeouts (GC freezes user threads), and memory dump analysis (no thread was doing actual work) supported the theory.

The solution, unfortunately, is to retool how the process uses memory.  I also threw in induced garbage collection in between steps to prevent generation 2 heap build-up.

iOS 5 and SIM-less FaceTime

With iOS 4, I was able to FaceTime using my cellphone number even if I take out the SIM card – all I needed to do was turn on the flight mode. Not anymore in iOS 5. I can no longer FaceTime using my phone number regardless of flight mode. It’s a bummer for me as I switch between phone using the same SIM card.

Interesting Driving Experience

I had an interesting experience while driving home today. The whole event happened in about two seconds with cars going at >= 65 mph on a three-lane highway:

  1. A truck and an Acura RSX sped by. Both were way over speed limit as I was at the speed limit.
  2. A ladder fell off from the truck while it was racing in the left lane.
  3. The ladder tumbled from left to the middle lane.
  4. I was driving in the right-most lane hoping the ladder would not tumble into my lane. I diverted to the right slightly but maintained my speed and drove past it.
  5. A full-size SUV was driving in the left lane. Seeing the ladder ahead, it changed to the middle lane.
  6. The ladder was in middle lane when the SUV ran it over.

Luckily the SUV ran over the ladder instead of hitting it when it was in mid air. Either way, I don’t think my car would fair as well even if I had just gone over the ladder.

Cars that managed to drive by, including the culprit truck, kept going, but that stretch of highway probably would be packed for a while.

Landline Disconnected

Today, after so many years, I have finally disconnected my landline. Hopefully this will unplug all the marketing calls coming in on that line – in fact those were the only calls coming on that line.

Governator 2010

Arnold Schwarzenegger came to Microsoft SVC campus on March 10, 2010 to launch the Elevate America program. I was there to capture a few photos.

Unfortunately the only telephoto lens at my disposal was the Nikkor ED 18-200mm f/3.5-5.6G IF DX VR. It was simply not fast enough for indoor, no flash shooting. I pushed my Nikon D80 to its barely-acceptable ISO1600 setting, but most photos still turned out blurry.

A few did turn out okay though, you can click on the photo on the left to see them all.

Math and Chinese

I was listening to the Outliers: The Story of Success audio book yesterday and a particular section had me thinking. It was the chapter on why Asian kids are better at math than their western peers, and it started with explaining how language mattered:

  • People can better memorize whatever that can be said in two seconds. More numbers can be recited in Chinese than in English.
  • Number counting is more logical in Chinese. In Chinese, 1 is “one”, 11 is “ten one”, 21 is “two ten one”. In English, 1 is one, 11 is “eleven”, 21 is “twenty one”. Also fourteen and forty sound too similar. Study showed that Asians kids can count up to 40 one year earlier than their Western peers. Asian kids can do mental calculations better because of this regularity.
  • In Chinese, fractions are cited in a manner that better describes the concept. For example, 3/5 is read as “out of five parts take three” in Chinese. In English it’s “three fifth”.

Here I use Chinese as example because I know the language. The book actually referred to Asian languages in general. The advantages in language makes Asians kids more interested in math. I remembered how easy it was to memorize the multiplication table in Chinese. I can still recite the table with a (albeit slower) rhythm. I can’t do that in English.

By the way, I absolutely recommend the book Outliers: The Story of Success.

Destructors and __interface

I have been mainly using C# and Java at work for the past few years. I know C++ but haven’t practiced it for a while. Recently at work I was required to pick up C++ again, and I found this peculiar behavior of __interface and destructors.

Example code:

__interface IAbc { };
class Abc : public IAbc
{
public:
virtual ~Abc() { printf("abc"); }
};

int _tmain(int argc, _TCHAR* argv[])
{
IAbc* abc = new Abc();
delete abc;
return 0;
}

~Abc() will not be invoked despite the explicit delete statement. This is because __interface does not allow destructors, thus virtual ~IAbc() is not possible.

This means the destructor won’t work in this case either:

auto_ptr<IAbc> abc(new Abc());

Since my original intention was to use auto_ptr, I ended up faking the interface using an abstract class. I lost the compiler enforcements of __interface, but at least I am freeing memory properly.

Avatar

I watched James’s Cameron’s movie “Avatar” today in what the Century 25 called XD 3D. XD meant higher definition pictures, better audio, and luxury seats. 3D of course meant I paid a bit more for the 3D glasses.

Because it was a XD showing, there was no matinee pricing even for the first showing of the day. Frankly I didn’t find the picture quality to be noticeably better than that of a normal theater. Same went for the audio. The seats were much more comfortable though.

The movie itself was pretty good in general, though the ending was predictable. It was long at 2.5 hours, but the pee holding was worth it. I didn’t think the 3d made the movie any better, but many people on twitter might disagree. I surprisingly liked the Na’vi characters (referred to as “blue cat people” by a radio DJ).

A lot of people clapped when the credits rolled at the end – the last time I saw this happening was for Terminator 2, also a James Cameron movie.

Scumbag day

Yesterday, December 1, 2009, would be known as scumbag day in my book.  It’s a day in which I encountered both low and high tech scumbags.

I encountered the low tech scumbag during my evening jog. At a somewhat dark street junction in my normal route, a young black teenager approached me, took out a knife from his pocket, and demanded for my iPhone. As he was still 2-3 meters away from me, I turned and ran the opposite direction. This punk didn’t pursue and instead ran towards a nearby parked car which took off quickly. Though I wasn’t physically harmed, what really pissed me off about this incident was that this was at a safe residential area, MY residential area!

Later in the same evening I noticed that there was a message in our answering machine. It was a somewhat automated voice asking us to call back 800-695-7020. The message said it was from World National Bank regarding Victoria Secret account. My wife dialed the number and almost gave her SSN upon prompt. Luckily I grew suspicious at the vague message and stopped her in time. A quick online search revealed that phone number to be a phishing scam. What irked me about this was that phishing scams were typically online, not in the physical world. These asshats just crossed the line.

So many bastards in this world.

Follow

Get every new post delivered to your Inbox.