Their is a technique for keeping track of a 'progressive average' so you only ever have two images in memory at any one time.
However I would suggest a different technique.
First recompile your IM so that it has HDRI enabled. This version of IM saves all values as floating point numbers, and can have these number exceed the normal 'black' and 'white' bounds.
Then in a API (not command line), you can loop though each image, reading them in one at a time
and add them together (use 'plus' composition). When finished divide all the image values by the number of images, which will bring the values back into normal black to white range, and save.
As HDRI (floating point values) is in use you should NOT have any problems averaging the images, and saving the results in this way.
For command line, I would do it in smaller pieces. Say averaging 10 to 20 images at a time together (whatever number can be comfortable retained in memory), then average 10 to 20 of the averages, and so on. You may have to use a 'blended average' to handle images that do not contain the same number of images, as the other averaged images, and that can be tricky, but you should be able to get a average of any number of images in this way.
WARNING: this last method may have Quantum rounding effects. Again I suggest you use the highest Quality level version of IM possible, and save to a intermediate image file format (such as MIFF) that does not introduce quantum rounding errors due to 'depth' restrictions. Again it may be better to use a HDRI version of IM.
See IM Examples, Basics,
Quality, Depth & HDRI
http://www.imagemagick.org/Usage/basics/#depth