Judging by your code sample,
$Output is a generic List collection.
For these collections,
Count is a count of the objects contained in the List currently.
Capacity is the currently allocated space for more objects to be added before it has to re-allocate a new collection internally to store more items.
List is a front-end that keeps an array hidden internally with (often) more capacity than it really strictly needs to have, because by design it’s expected that you’ll be adding or removing items from the list, and having a bit of additional capacity is helpful to avoid expensive operations where it has to re-allocate an entire new array because it runs out of space.
So you can think of
Count as the size of the List, but
Capacity is the size of the currently-allocated internal array where items are actually stored. Once
Count reaches the
Capacity value, the List will automatically re-allocate a new array the next time you
.Add() to the List – if I recall correctly, the new array it allocates is typically double the size of the one whose capacity you’ve just exceeded. So, when adding many items to the list, you’ll see its
Capacity change as it allocates new arrays whenever it’s needed.
If you already know the approximate size of your List (within, say, an order of magnitude or thereabouts), you can actually specify its initial
Capacity by either:
- Creating the list with a preset initial capacity with
$Capacity is an integer.
- Creating the list by passing in an existing array for it to copy. It will have an initial capacity equal to the size of the array, if I recall correctly:
So the fact that it has additional
above and beyond your actual
of objects is simple an implementation detail; you don't have additional items hiding in your List that aren't being exported.
Your problem with blank exported files is coming from somewhere else.