The Tableau Desktop program will query directly from the data source when it is set to be a live connection vs. an extract. Tableau Desktop will sometimes leverage a cache to lessen the load on the data source as well as speed up performance of the view. This cache will automatically be refreshed when the refresh action is used in Tableau Desktop. I believe this is what you are referring to when discussing the data being stored in the RAM of the machine.
To clear the cache manually, check out the Knowledge Base article below:
Additionally, the cache can also be disabled for Tableau Desktop, which will prevent the program from creating an external cache.
Hope this helps!