When you have Kafka problems with
java.lang.OutOfMemoryError: Java heap space
it doesn’t necessarily mean that it’s a memory problem. Several Kafka admin tools like kafka-topics.sh will mask the true error with this when trying to connect to an SSL PORT. The true (masked) error is SSL handshake failed !
See this issue: https://issues.apache.org/jira/browse/KAFKA-4090
The solution is to include a properties file in your command (for kafka-topics.sh this would be --command-config) and to absolutely include this line:
security.protocol=SSL