I am a web developer, and sometimes I encounter software bugs that has runaway threads or used up available memory in a browser process. Terminating the offending Chrome process will free up the memory usage, but kernel_task still use up a huge chunk of memory
Running sudo /usr/sbin/purge does not make any impact on the used memory.
How can I get kernel_task to free those unneeded memory?

All Processes, Hierarchally, you should be able to see more information. Please post a screenshot. It looks like you have several Firefox Nightly Web Content that could be contributing. – Unassuming Guy Apr 05 '18 at 17:29