Use the Java plugin for the Cloud Foundry command line interface to get heap dumps, thread dumps and profiling data (JFR or async-profiler).
Before using the extended commands, you first need to install the Java plugin in the Cloud Foundry environment.
See: Install the Java CLI Plugin in the Cloud Foundry Environment