On normal computers, heap will be cleaned as you close the program, but can I save data to Arduino's heap with
malloc function. And will it be cleaned after I power off the Arduino?
Yes, you can use
malloc() on the Arduino - however it is not something I would recommend you use since memory is at a premium and excessive use of
free() causes heap fragmentation which can eat your memory up and cause random crashes (
String is the biggest culprit of this).
I am not sure what you mean by "clean" the memory. When power is removed the content of the memory is lost. The whole of the SRAM forgets its contents if there is no power to maintain that state. A bit like when you unplug your computer it "forgets" that Windows is loaded.
If you want to retain information with the power removed you need to use the EEPROM.