OOM exceptions for kafka connect

I have written a kafka connect jar and I get below error:

I have provided KAFKA_HEAP_OPTS="-Xmx8g" in kafka-run-class. Also with respect to connect-offsets I have provided 50 partitions. I am running it as part of docker and have set 8 GB memory specifically set for the container. Please let me know if there is any important parameter to set to make sure OOM exceptions are not thrown.

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "KafkaBasedLog Work Thread - connect-status"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "kafka-producer-network-thread | producer-4"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "kafka-producer-network-thread | producer-3"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "kafka-producer-network-thread | producer-2"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "DistributedHerder"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "qtp667346055-26"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "KafkaBasedLog Work Thread - connect-offsets"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "KafkaBasedLog Work Thread - connect-configs"
Exception in thread "org.eclipse.jetty.server.session.HashSessionManager@7d9d0818Timer" java.lang.OutOfMemoryError: Java heap space
2017-10-13 11:50:52,320 ERROR   Task METEOSATJDBCSink-0 threw an uncaught and unrecoverable exception during shutdown   (org.apache.kafka.connect.runtime.WorkerTask:123)
java.lang.OutOfMemoryError: Java heap space