class HeapSizeSanityChecker {

    void sanityCheck( Input.Estimates inputEstimates, RecordFormats recordFormats, MemoryStatsVisitor.Visitable baseMemory,
            MemoryStatsVisitor.Visitable... memoryVisitables )
    {
        // At this point in time the store hasn't started so it won't show up in free memory reported from OS,
        // i.e. we have to include it here in the calculations.
        long estimatedCacheSize = estimatedCacheSize( baseMemory, memoryVisitables );
        long freeMemory = freeMemoryLookup.getAsLong();
        long optimalMinimalHeapSize = optimalMinimalHeapSize( inputEstimates, recordFormats );
        long actualHeapSize = actualHeapSizeLookup.getAsLong();
        boolean freeMemoryIsKnown = freeMemory != VALUE_UNAVAILABLE;

        // Check if there's enough memory for the import
        if ( freeMemoryIsKnown && actualHeapSize + freeMemory < estimatedCacheSize + optimalMinimalHeapSize )
        {
            monitor.insufficientAvailableMemory( estimatedCacheSize, optimalMinimalHeapSize, freeMemory );
            return; // there's likely not available memory, no need to warn about anything else
        }

        // Check if the heap is big enough to handle the import
        if ( actualHeapSize < optimalMinimalHeapSize )
        {
            monitor.insufficientHeapSize( optimalMinimalHeapSize, actualHeapSize );
            return; // user have been warned about heap size issue
        }

        // Check if heap size could be tweaked
        if ( (!freeMemoryIsKnown || freeMemory < estimatedCacheSize) && actualHeapSize > optimalMinimalHeapSize * 1.2 )
        {
            monitor.abundantHeapSize( optimalMinimalHeapSize, actualHeapSize );
        }
    }

      HeapSizeSanityChecker( ImportLogic.Monitor monitor );
      HeapSizeSanityChecker( ImportLogic.Monitor monitor, LongSupplier freeMemoryLookup, LongSupplier actualHeapSizeLookup );

}