Good, Better, Best...Bester?

| | Comments (9)

Hiya,

In previous articles, I've explained how Jing for Windows (winJing) has had issues with poor memory management and that, though we've cleaned them up, Jing may still appear to occupy a fair bit of memory.

Investigating and fixing these memory issues has been quite an adventure and I thought I'd share...in slightly cutesy form.

[fade in]

Jing's Memory Usage
Finding, Fixing and Faking(?)


{Opening credits go here}


In the beginning, Jing was a good application.

It allowed me to share quickly and simply.

It stayed out of my way, but was there when I needed it.

However, it was the biggest memory hog on my machine. And as one of its developers, that was very embarrassing. So I made some time to see what I could do about it.

To lay a baseline, I did seven full screen (dual monitor) image captures and saved each to the Desktop.

The resulting Jing memory usage was ridiculous.



After each capture, the memory lept a mile and never leveled off or decreased. The unbounded and continuous growth was a strong indicator of poor memory management on our part.

So, I set off looking for problems. And golly did I find some doozies.

Shame on me.

After taking some time to track those down and mop them up, I repeated the seven image captures.




After the first three captures, the Mem Usage leveled out and remained pretty much unchanged thru capture seven.

The worst memory management problems seemed to be fixed.

'Well that's better' I thought...er...said...outloud...to myself.

"Hmm...But I know what might be best..."

The .NET framework (which winJing uses ) cleans up unused memory via something called 'garbage collection'. It does this infrequently because it has to completely stop the application and it takes a bit of processor time.

But I figured, maybe I could call it manually.

I mean, I know what I'm doing, right?

I am so smart! S - M - R - T! And all that.

So I did it manually and this is what I got:



"Cool! Yup. That's the best." I thought.

"But I should probably be sure there isn't something bester."

I did a little looking around and eventually I found a function...a special, magical function.

Real Harry Potter stuff.

And bam! Pow!




"Wow! That's the Bestest! I've shrunk Jing to 29 MB of memory!"

That's impressive, especially for a multimedia .NET application.

I was pleased with myself, but unfortunately, it wasn't true.

As I have stated in this article, only looking at 'Mem Usage' can be misleading.

What I really wanted to look at was the Virtual Memory Size ('VM Size' in XP or 'Commit Size' on Vista). That would more accurately reflect the affect my code changes were having.

If we look at Virtual Memory Size, we can see the fuller story of my improvements, and reveal the true result of the amazing memory shrinking function.



Good Jing (poorly managed memory):





Better Jing (better memory management):






Best Jing (better memory management and manual garbage collection):





Bester Jing? (better memory management, manual garbage collection and magic (Jinguloso! with wand flick)):





Now, I think comparing these numbers directly, requires a big lump of salt, because the .NET framework is managing the memory. But I think the expansive differences here make it validish to do.

So, cleaning up my poor memory management gained me about 167 MB!

167MB...wow...how embarrassing.

Attempting to do my own garbage collection got me another 32 MB.

But at what cost?

Garbage collection has to stop the entire application and is CPU intensive. And when done manually, it has to be called twice to be 'sure' it worked.

Lastly, my special, magical function resulted in a HUGE 103 MB savings in Mem Usage even after the other 'improvements'!

But it didn't do anything to reduce winJings actual memory size (You can clearly see why the Mem Usage is not the column to watch for memory leaks).

So what did the special, magical function do?

It forced Jing out of RAM and into paged memory. It essentially forces the Mem Usage to be as small as possible, but Jing's actual memory size is unchanged.

So, it doesn't make Jing any smaller.

However, that doesn't mean it's not useful.

It is still good to take up less RAM when you aren't using it. The OS actually calls this magic function when applications are minimized to make room in case any foregrounded applications need it.

Jing, however, is never minimized. It's always there, even when you aren't using it. Because of this, we'll be looking into possibly calling this function in future releases. But we'd only do so if we find it actually improves system performance and is safe.

We won't call it just to fake people out and make Jing's memory size look smaller. :)

As for garbage collection, we decided it's better to let .NET do what it's designed to do, keep an eye on our memory management and try to explain what is going on to users who inquire why a 'light, simple sharing app' is taking up 200MB of Mem Usage.

So, in the end, I only improved our memory management. But it should be a huge improvement. And we'll continue looking for other improvements as we try to make Jing as lean and mean as possible.

have a good day,
bill 'I think I'll make my own 29 MB build of Jing...it just looks so cool…ignorance is bliss' scanlon

Bookmark and Share

9 Comments

Is there any way to upload jing videos for mac to youtube? I've noticed that they are in swf format...

Thanks.

Quote floater

I am having trouble using this - mainly because I want to save the recorded video to my HD, not necessarily to Screencast (because it won't let, for one). The folder where it's supposed to go is empty - and I see no SAVE button.
I'm reviewing this program for my own web viewers, so a reply would be helpful.
Thanks!

Quote floater

@omegareport

There are a bunch of How to's here

How to save specifically is here

Quote floater

Or, you could just cut all the .net crap and recode it using the Win32 framework. This would result in smaller memory footprint at all levels and the application won't stall during garbage collection.

Quote floater

@Mark

Very true, very true...and not out of the question :)

Quote floater

@Jason

I'll give you a hint. The function allows you to set the process working set size. :)

Quote floater

http://tinyurl.com/6lbc5l
http://tinyurl.com/5b49ey

Look this screens..I have problem at the proccesor and the ram.
I have 2gb ddr2 and core2duo proccesor.

At Camtasia i have not this problems.Can you fix it please?

Thank you

Quote floater

@Thodoris:

I'll try to look into the cpu usage. Seems high

The memory usage seems about right for 2 GB RAM. .NET takes up a lot of memory if there's a lot available.

See this blog post for more:

http://blog.jingproject.com/2008/04/jing_for_windows_memory_usage.html

Also, for memory usage, this blog post tells you which column to watch:

http://blog.jingproject.com/2008/04/watching_for_leaks_in_jing_for.html

Quote floater

louis vuitton wallets replica louis vuitton fake lv travel handbags

Quote floater

Jing Support/Feedback

Leave a comment


Type the characters you see in the picture above.

About this Entry

This page contains a single entry by Bill Scanlon published on April 24, 2008 9:29 AM.


Previous Entry:
Jing and The Mega Huge Email Attachment

Next Entry:
What’s going on with the Jing Project?/ Making the Best Jing Possible


Find recent content on the main index or look in the archives to find all content.