c# - How to refer to children in a tree with millions of nodes -


i'm attempting build tree, each node can have unspecified amount of children nodes. tree have on million nodes in practice.

i've managed contruct tree, i'm experiencing memory errors due full heap when fill tree few thousand nodes. reason because i'm attempting store each node's children in dictionary data structure (or data structure matter). thus, @ run-time i've got thousands of such data structures being created since each node can have unspecified amount of children, , each node's children stored in data structure.

is there way of doing this? cannot use variable store reference of children, there can unspecified amount of children each node. thus, not binary tree have 2 variables keeping track of left child , right child respectively.

please no suggestions method of doing this. i've got reasons needing create tree, , unfortunately cannot otherwise.

thanks!

how many of nodes "leaf" nodes? perhaps create data structure store children when first have child, otherwise keeping null reference.

unless need children map, i'd use list<t> (initialized appropriate capacity) instead of dictionary<,> children. sounds may have more requirements you've explained though, makes hard say.

i'm surprised you're failing after few thousand nodes though - should able create pretty large number of objects before having problems.

i'd suggest if think you'll end using lot of memory, make sure you're on 64-bit machine , make sure application set 64-bit. (that may thin wrapper on class library, fine long class library set 64-bit or anycpu.)


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -