For Programmers: Reduce Your Graph Data Provider's Memory Usage

Jun 11, 2012 at 8:08 PM
Edited Jun 12, 2012 at 1:10 AM

If you are a programmer and you have created a NodeXL graph data provider, you can make a small change to your provider that might significantly reduce the amount of memory it uses.  Many users of the built-in Twitter, Flickr and YouTube providers have reported OutOfMemoryException errors, and if your users have encountered these errors, too, then you should consider making this change.

You are not required to change anything in your provider.  NodeXL will continue to work with older providers if you decide not to modify yours.

To modify your graph data provider to use less memory:

1. Download the latest NodeXL Class Libraries from the NodeXL Downloads tab at  You need version number or later.

2. Reference the new Microsoft.NodeXL.ExcelTemplatePlugIns.dll assembly in your graph data provider project.

3. Derive your graph data provider class from IGraphDataProvider2 instead of IGraphDataProvider.  Change this:

    public class MyGraphDataProvider : IGraphDataProvider

to this:

    public class MyGraphDataProvider: IGraphDataProvider2

4. Replace your TryGetGraphData() method with TryGetGraphDataAsTemporaryFile().  Change this:

    public Boolean TryGetGraphData(out String graphDataAsGraphML)

to this:

    public Boolean TryGetGraphDataAsTemporaryFile(out String pathToTemporaryFile)

5. Return your GraphML in a temporary file instead of as a string.  Change this:

    graphDataAsGraphML = xmlDocument.OuterXml;

to this:

    pathToTemporaryFile = System.IO.Path.GetTempFileName();

6. Test your updated provider with the latest version of the NodeXL Excel Template.

Note that if you derive your class from IGraphDataProvider2 instead of IGraphDataProvider, as I'm recommending here, your updated provider will not work with older versions of NodeXL.  If you want your updated provider to work with both old and new versions of NodeXL, you can implement both IGraphDataProvider and IGraphDataProvider2, in which case older versions of NodeXL will continue to use your IGraphDataProvider implementation, while newer versions will use your IGraphDataProvider2 implementation.

-- Tony