Graph Structure Memory Requirements
Questions & AnswersSummary
Description
The tables below give an overview of the approximate memory consumption for nodes and edges on 32-bit and 64-bit runtime environments. True 64-bit systems (operating system plus Java Runtime Environment) allow to use much larger memory spaces than 32-bit systems (see also: Java Tuning White Paper).
Graph: Basic Graph Structure
In a Graph only the basic graph structure is stored, i.e., only structural information. Essentially, this means information like "node A is connected to node B" (by an edge).
The following table shows the approximate memory consumption when creating graph elements.
| Node | Edge | Notes | |
|---|---|---|---|
| bytes (approx.) | |||
| 32-bit | 80 | 80 | Structural information only. |
| 64-bit | 96 | 96 | |
For more information concerning the basic graph structure types, please see the corresponding section in the yFiles Developer's Guide.
DefaultLayoutGraph: Additional Layout Information
In a DefaultLayoutGraph, nodes and edges additionally hold layout information.
This includes position and dimensions for nodes and positions of control points for edges (more precisely their edge paths).
Control point, or simply point, subsumes both bends and ports of an edge path.
DefaultLayoutGraph inherits from class y.base.Graph.
The following table shows the approximate memory consumption when creating graph elements.
| Node | Edge | Notes | |
|---|---|---|---|
| bytes (approx.) | |||
| 32-bit | 124 | 164 | Includes layout information. |
| 64-bit | 148 | 192 | |
When adding a point (bend) to an edge using method EdgeLayout.addPoint(double, double), memory consumption (32-bit / 64-bit) increases by 26 bytes / 34 bytes (approx.). The same holds true for setting either source point (port) or target point (port).
For more information concerning the layout graph structure types, please see the corresponding section in the yFiles Developer's Guide.
Graph2D: Additional Information for Visual Representation
In a Graph2D, nodes and edges are additionally associated so-called realizers that are responsible for the visual representation of the graph element.
Graph2D inherits from class y.layout.LayoutGraph (which itself inherits from y.base.Graph).
The following table shows the approximate memory consumption when creating graph elements.
| Node | Edge | Notes | |
|---|---|---|---|
| bytes (approx.) | |||
| 32-bit | 504 | 348 | Default realizers are used for the visual representation, i.e., ShapeNodeRealizer and PolyLineEdgeRealizer. |
| 64-bit | 594 | 410 | |
When adding a Bend object to an edge realizer using method appendBend, memory consumption (32-bit / 64-bit) increases by 58 bytes / 70 bytes (approx.). Additional NodeLabel and EdgeLabel objects (empty, i.e., without text) add 216 bytes / 236 bytes (approx.) and 314 bytes / 358 bytes (approx.) to the memory footprint (32-bit / 64-bit) of a graph. Note that node realizers already hold one empty NodeLabel when created.
// 'g' is of type y.view.Graph2D.
// 'n' is of type y.base.Node, 'e' is of type y.base.Edge.
// Adding a NodeLabel to a node.
g.getRealizer(n).addLabel(g.getRealizer(n).createNodeLabel());
// Adding an EdgeLabel to an edge.
g.getRealizer(e).addLabel(g.getRealizer(e).createEdgeLabel());
Using ImageNodeRealizer instead of ShapeNodeRealizer for the visual representation of nodes needs 464 bytes / 542 bytes (approx.) per node.
An additional 50KB / 360KB (approx.) is allocated statically with class ImageNodeRealizer for managing the static image cache.
Images that are added to the image cache can be shared among ImageNodeRealizer instances, i.e., if multiple nodes use the same image, it is only needed once in the cache.
For more information concerning the visual graph structure types, please see the corresponding section in the yFiles Developer's Guide.
Hierarchically Organized Graph2D
Group nodes and folder nodes in hierarchically organized graphs that are created using HierarchyManager's
createGroupNode(Graph) /
createFolderNode(Graph) methods, consume 1070 bytes / 1430 bytes (approx.) and 2288 bytes / 2962 bytes (approx.), respectively (32-bit / 64-bit).
By default, for the visual representation of both group nodes and folder nodes GroupNodeRealizer is used.
If DefaultHierarchyGraphFactory's setProxyNodeRealizerEnabled is set to true, however, ProxyAutoBoundsRealizers with two delegate GroupNodeRealizers are used instead.
Upon creation of a group node or folder node, then 2316 bytes / 2627 bytes (approx.) or 3500 bytes / 3933 bytes (approx.), respectively add to the memory footprint (32-bit / 64-bit) of a graph.
The difference in size between group node and folder node stems from the fact that when a folder node is created, an additional Graph2D is created to hold the inner graph of the folder.
For more information concerning realizers in hierarchically organized graphs, please see the corresponding section in the yFiles Developer's Guide.