Goodness of fit tests look at distributions. Distributions can be normalised to the total number of samples in a group so there is no need for the groups to be identical in size. However, there should not be too large a discrepancy as the smoothness of the histograms should be comparable.