Sign in
Calvin Hsia's WebLog
thoughts from a professional developer
Options
Email Blog Author
RSS for Posts
Atom
RSS for Comments
OK
Search
Advanced search options...
Search In:
Everything
Blogs
Forums
People
Groups
Places
Pages
Date range:
All Time
Last Year
Last 6 Months
Last 3 Months
Last Month
Last Week
Last Two Days
Search
Tags
64bit
C++
CSharp
Debugging
FunGames
History
LINQ
Memory
Mesh
Miscellaneous
Pictures
Programming
SmartPhone
Testing
VB
Vista
Visual FoxPro
Visual Studio
Web
Windows API
WPF
Archive
Archives
August 2010
(1)
July 2010
(1)
June 2010
(1)
May 2010
(1)
April 2010
(1)
March 2010
(2)
February 2010
(1)
January 2010
(1)
December 2009
(1)
November 2009
(1)
October 2009
(1)
September 2009
(1)
August 2009
(1)
July 2009
(1)
June 2009
(1)
May 2009
(1)
April 2009
(1)
March 2009
(2)
February 2009
(1)
January 2009
(2)
December 2008
(1)
November 2008
(1)
October 2008
(1)
September 2008
(1)
August 2008
(1)
July 2008
(3)
June 2008
(2)
May 2008
(2)
April 2008
(2)
March 2008
(2)
February 2008
(2)
January 2008
(2)
December 2007
(3)
November 2007
(8)
October 2007
(6)
September 2007
(4)
August 2007
(9)
July 2007
(2)
June 2007
(2)
May 2007
(11)
April 2007
(5)
March 2007
(2)
February 2007
(2)
January 2007
(1)
December 2006
(2)
November 2006
(1)
October 2006
(4)
September 2006
(6)
August 2006
(10)
July 2006
(13)
June 2006
(11)
May 2006
(7)
April 2006
(8)
March 2006
(14)
February 2006
(5)
January 2006
(21)
December 2005
(9)
November 2005
(19)
October 2005
(20)
September 2005
(12)
August 2005
(23)
July 2005
(12)
June 2005
(8)
May 2005
(7)
April 2005
(4)
March 2005
(1)
February 2005
(2)
January 2005
(13)
December 2004
(9)
November 2004
(4)
October 2004
(10)
September 2004
(4)
August 2004
(8)
July 2004
(1)
June 2004
(10)
MSDN Blogs
>
Calvin Hsia's WebLog
Posts
Subscribe via RSS
Sort by:
Most Recent
|
Most Views
|
Most Comments
Excerpt View
|
Full Post View
Calvin Hsia's WebLog
Use Perfmon to analyze your managed memory
Posted
Fri, Aug 27 2010
by
Calvin_Hsia
0
Comments
You can learn all sorts of information about your application using Perfmon. You can also inspect various aspects of managed memory. How much time is spent in garbage collection? When managed code runs, memory management is done for you, but at the cost...
Calvin Hsia's WebLog
Use inline XAML with clr-namespace to create a Styled Treeview
Posted
Wed, Jul 28 2010
by
Calvin_Hsia
0
Comments
Writing WPF code is made easier in VB because of the built in XML features (XAML is really XML). Here is a sample that creates a TreeView of some folders on disk. Suppose we want to add a Trigger style that will fire when the mouse is over an item. We...
Calvin Hsia's WebLog
Using multiple heaps efficiently
Posted
Fri, Jun 25 2010
by
Calvin_Hsia
1
Comments
You can inspect the processes that run on your machine using Task Manager (Ctrl-Shift-Escape) or , Process Explorer from Sysinternals Or you can write your own: here’s source code: What is your computer doing with all that memory? Write your own...
Calvin Hsia's WebLog
Managed code using unmanaged memory: HeapCreate, Peek and Poke
Posted
Sun, May 30 2010
by
Calvin_Hsia
0
Comments
In the old days of Basic (starting over 4 decades ago), there were functions called Peek and Poke that would allow you to read and write memory directly. These were incredibly powerful commands: you could, for example, read and write directly to the hardware...
Calvin Hsia's WebLog
Sometimes you want 2 returned values: playing around with Tuples
Posted
Thu, Apr 29 2010
by
Calvin_Hsia
2
Comments
When writing code in various languages, you’ll write functions from which you get a return value. Sometimes you’ll want to get 2 return values. A common way to handle this is to use parameters to pass a variable by reference that will get one of the return...
Calvin Hsia's WebLog
Use Named Pipes and Shared Memory for inter process communication with a child process or two
Posted
Tue, Mar 30 2010
by
Calvin_Hsia
0
Comments
I wanted to inject some very low impact code that would run in any “parent” process, like Notepad or Excel or Visual Studio. I wanted to have some User Interface for the data that my injected code gathered about the parent process, and that would work...
Calvin Hsia's WebLog
Use a Custom Allocator for your STL container
Posted
Tue, Mar 16 2010
by
Calvin_Hsia
0
Comments
Last time in Play around with .Net Dictionaries and STL maps , we talked about various containers. Today we’ll write our own allocator for a particular STL container. A general purpose allocator, like malloc in the C Runtime library or HeapAlloc in the...
Calvin Hsia's WebLog
Play around with .Net Dictionaries and STL maps
Posted
Mon, Feb 15 2010
by
Calvin_Hsia
0
Comments
Last time ( Adventures in interop code: explore string interop memory ) we investigated sharing memory between native and managed code, or between processes. Data structures are very useful: things like arrays, structures, lists, dictionaries, stacks...
Calvin Hsia's WebLog
Adventures in interop code: explore string interop memory
Posted
Fri, Jan 29 2010
by
Calvin_Hsia
1
Comments
In Create an ActiveX control using ATL that you can use from Fox, Excel, VB6, VB.Net , I showed how to create a control (with which the user can interact) which can be hosted in many places. Today’s sample creates a class in C++ that doesn’t necessarily...
Calvin Hsia's WebLog
You can develop code faster
Posted
Wed, Dec 16 2009
by
Calvin_Hsia
4
Comments
You can make your Visual Studio experience faster. Often you write some code in Visual Studio, hit F5 to test the code. Repeat. Here’s a simple way to make this experience faster. (works with managed, native, mixed code). When a process is started from...
Calvin Hsia's WebLog
Look at some hdden code in your VB project
Posted
Mon, Nov 30 2009
by
Calvin_Hsia
3
Comments
Some code is always added to your VB project. Try this: Start VS (2008 or 2010 beta: the numbers below are for 2008) File->New->Project->VB->Console App. Build->Build Solution. (I like to use temporary projects: see Use temporary projects...
Calvin Hsia's WebLog
What is your computer doing with all that memory? Write your own memory browser
Posted
Mon, Oct 19 2009
by
Calvin_Hsia
1
Comments
What is your computer doing with all that memory? There are various kinds of memory allocated and used in each process. These include: · Managed memory (VB.Net, C#, managed C++) · Heap memory · Stacks · Images (files loaded into a process) VirtualAlloc...
Calvin Hsia's WebLog
Its easy to create a graph of memory use in Excel
Posted
Mon, Sep 28 2009
by
Calvin_Hsia
0
Comments
In this post Examine .Net Memory Leaks I showed how to find a .Net managed memory leak. Now let’s create a graph of memory and resource use over time. Start Visual Studio 2008, File->New->Visual Basic (or C#) Windows, WPF application. Dbl click...
Calvin Hsia's WebLog
Make your Task Switcher Window bigger
Posted
Fri, Aug 21 2009
by
Calvin_Hsia
0
Comments
One of the best features of Windows is the ability to Cut and Paste data within an application or from one application to another. You can alt-tab or click on the task bar to switch between actively running applications, like Word and Visual Studio. When...
Calvin Hsia's WebLog
Process Explorer and Process Monitor can help you understand a program
Posted
Wed, Jul 29 2009
by
Calvin_Hsia
0
Comments
Process Explorer and Process Monitor are must-have free utilities that you can download from http://technet.microsoft.com/en-us/sysinternals/bb795533.aspx For example you can use ProcExp to examine a particular behavior of Visual Studio. Start Visual...
Calvin Hsia's WebLog
You can use Visual Studio to debug itself!
Posted
Mon, Jun 8 2009
by
Calvin_Hsia
2
Comments
How do you find out why your computer or a running program is so slow? Here’s one way. Let’s attach the VS debugger to VS itself. The main executable for VS is devenv.exe. Start Visual Studio 2008. This will be the “debugger” Choose File->Open Project...
Calvin Hsia's WebLog
Stack overflow, expand your stack? Change your algorithm!
Posted
Thu, May 28 2009
by
Calvin_Hsia
1
Comments
In the last post, Area fill algorithm: crayons and coloring book , I showed a program that emulates a kid drawing in a coloring book. However, the algorithm wasn’t very efficient, and would explode even if you had a simple drawing: it was using the stack...
Calvin Hsia's WebLog
Area fill algorithm: crayons and coloring book
Posted
Thu, Apr 30 2009
by
Calvin_Hsia
4
Comments
Kids know how to use crayons and a coloring book. How do you write such a program? In my last post ( Which pixels do you turn on when you draw a line? ) I showed how to draw a line. Now suppose you have some lines or shapes already drawn. How would you...
Calvin Hsia's WebLog
Which pixels do you turn on when you draw a line?
Posted
Mon, Mar 30 2009
by
Calvin_Hsia
3
Comments
When I wrote my cartoon animation program almost 30 years ago (see Cartoon animation program ) I needed to know how to draw a line. Of course, nowadays, we just call a library function that will draw a line given two points. If you think about it, the...
Calvin Hsia's WebLog
Comment/Uncomment code to switch versions quickly without using macros
Posted
Sat, Mar 28 2009
by
Calvin_Hsia
7
Comments
In a typical day, I write or debug programs in several languages: typically Foxpro, C#, VB, C++ and 32 bit assembly, with an occasional MSIL, IDL and 64 bit ASM thrown in. Sometimes, I like to switch between one version of code and another. This is useful...
Calvin Hsia's WebLog
Unorthodox chopsticks
Posted
Sat, Feb 28 2009
by
Calvin_Hsia
7
Comments
Several years ago, my wife and I were walking through a local shopping mall. At the time, there was some sort of Asian festival. At a display booth there was a table upon which were two trays, side by side. One was empty, and the other had many beans...
Calvin Hsia's WebLog
Cartoon animation program
Posted
Thu, Jan 29 2009
by
Calvin_Hsia
16
Comments
A cartoon can be thought of as a series of drawings. To simulate movement, the drawings can be slightly different from each other. Remember drawing simple cartoons using a pad of paper? Simply flipping through the pages made the drawings come to life...
Calvin Hsia's WebLog
Overload Operator new to detect memory leaks
Posted
Mon, Jan 19 2009
by
Calvin_Hsia
5
Comments
There are various leak detection methods for memory allocators. A popular one is to tag each allocation with some information about the caller. When there’s a memory leak, you just need to look at that tag info to find the line of code that allocated...
Calvin Hsia's WebLog
Write simple Debug helpers to help you debug and maintain your code
Posted
Wed, Dec 3 2008
by
Calvin_Hsia
3
Comments
Much of my time is spent using the Visual Studio debugger examining code to figure out how it works and how to fix it. When stepping through a function, the values the function uses are very useful for code understanding. The debugger shows these values...
Calvin Hsia's WebLog
You can use HWndHost to host a Win32 HWnd window inside a WPF element
Posted
Sat, Nov 29 2008
by
Calvin_Hsia
1
Comments
Suppose you have some old code lying around that creates a Win32 window with an HWnd (perhaps ATL , MFC , or just C/ C++). For example, if you type some erroneous code into a VB application in Visual Studio: Dim x=4: catch ex As Exception The “Exception...
Page 1 of 16 (376 items)
1
2
3
4
5
»