kernel_task and mdworker use all available RAM memory I am using a MacBook Pro 13" retina early 2015, running macOS 10.12 Sierra public beta 2. 

For the last two days my computer is not usable since there is no available RAM memory to use, the OS is just freezing and after few minutes the computer restarts itself.  

I checked the activity monitor to see what is the cause of that problem and I noticed that the kernel_task, the mds_stores, the mdworker and the mdworker32 tasks are using all of my RAM memory.


Turns out that it doesn't matter if some program is running on my computer or not, it happens every time I turn on my computer.  

I recently purchased a TarDisk for my Mac, a microSD card for expanding the computer's memory.
The problem mentioned above started right after the "Pearing" process.
I understood that the mdworker task is a system software that takes care of Spotlight indexing. 
Since the "pearing" process of the TarDisk makes the OS to think the microSD card is part of the main Macintosh HD and since I have turned on FileVault again after the installation, I think Spotlight has difficulties indexing my SSD for some reason that has something to do with that.  

In order to solve this, I tried to fix any possible flaws in my SSD.
So I have booted into Single-User Mode and run the file system consistency check command fsck -fy until it said the volume appears to be OK. I also run the First Aid tool on the Disk Utility app.
(Just to be clear, I have preformed those steps before installing the TarDisk, as the company instructed before beginning that installation process, but right now I am describing the steps I took in order to fix the problem mentioned above, after it appeared)
In addition, I have also restarted the System Management Controller (SMC) on my Mac, following the instructions on apple's site.
Non of the above worked for me.
I saw a way to disable Spotlight's indexing for the entire SSD, but I don't want to do that, since it will make Spotlight unusable for searching things and that is the entire point of this tool.  

I would like to get any suggestions for solving this issue.
What may cause it and what is a possible solution?
First of all, kernel_task gets higher (if I not wrong) because of the mdworker.

Talking now about the mdworker. Maybe the problem is not on your SSD at all. In this article recommends you to turn off Spotlight all devices. I recommend you to test instead with some folders of the SSD you might think Spotlight could get stuck in (large number of files, symlinks, ...). Also, you could try avoiding Spotlight accessing your external disks. Test until you get rid of the problem. Maybe you could find where the problem comes.

Also, you could try mdworker process always at 100%, even when not indexing this answer. Here founds that the problem resides in a Spotlight plugin. That could also be.