Memory use of Dynamically expanding TreeView

I created a tool a few years ago that uses a WPF TreeView with huge numbers of nodes. The branching factor is pretty high (the number of branches per level), and the depth can be several hundred levels. Of course, creating the whole tree would consume huge amounts of memory and processing time. This is…

0

Mapped Files give very fast access to huge amounts of data

Sometimes you write a program and it requires lots of extra storage. Perhaps it needs to deal with lots of information. If the requirements are large there are several alternatives to consider: 1. use main process memory (HeapAlloc, VirtualAlloc, or any API that eventually calls these, such as C++ new, C# new, etc). a. 32…

0

Visual Sorting Algorithms part II

In the days before the internet, email and cell phones: My ice hockey team was in the locker room talking about skating when the topic of a video showing me roller staking in Boston in 1980. https://www.youtube.com/watch?v=IxlV_lOLmrk see Visual Sorting Part I Below is the new version that uses a background thread to do the…

0

Use C++ to show memory use in an Excel Pivot table

(apologies for the formatting: The MSDN blog infrastructure has changed and some tools aren’t working yet) The CComDispatchDriver class is very useful, but it doesn’t work too well with Excel. It makes it easier to call many Automation interfaces (IDispatch). PropertyGet and PropertyPut, Invoke Method You can see the typedef of CComDispatchDriver in typedef CComQIPtr<IDispatch,…

0

Heap Corruption Exception 0xC0000374

Modern computers can execute millions of instructions per second, and if one of them is erroneous, then the process could crash. Often analysis of a crash dump can immediately indicates what the problem is, so the fix is easy. For example a NullReference exception: declare a Process variable with a null value, then try to…

0

Debugger features help to find memory leaks

You can use the debugger $CALLSTACK and TracePoints to find memory leaks. Memory leaks are very tedious to find. Often they don’t affect an application at all except a gradual performance slowdown on a customer machine. Leaks can be found in old code bases that have multiple authors over years, with different programming styles and…

2

How to monitor and respond to memory use

A colleague asked me how to run code in response to low memory condition. Apparently, data is buffered and can be flushed to disk or a server when memory gets low. So I showed him the code below. Start Visual Studio File->New->Project->C# WPF application Paste in the code below in the MainWindow.Xaml.cs file Then hit…

0

See how often your code runs and how much time it takes

Last post I showed how to create your own CLR profiler. This time, we’ll add a little code to run whenever a managed method is entered and exited. We’ll do this by signing up for the  Enter and Leave function hooks by calling ICorProfilerInfo2->SetEnterLeaveFunctionHooks2 . This will allow us to count how many times a…

0

Does the CLR release memory when no longer needed?

A colleague asked the other day if the CLR releases memory when it’s no longer needed. Suppose you allocate lots of memory, then release it. The CLR will grow the managed heap (the green below), but it will also shrink it if it can. All memory in a process must come from a pool of…

0

Turn your tests into stress tests easily

It’s great to be able to write tests and execute them while developing a project. While I’m developing, I can hit a button and run the dozens of tests to see if I’ve broken anything. As code gets written lots of things get refactored, moved around, etc. Hitting a button to see if I broke…

0