I create a table in memory like this:
temptable <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>CreateTable_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"in_memory"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"tableinmemory"</SPAN><SPAN class="punctuation token">,</SPAN>template<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">### house dir is null or street dir is null; item1 & item2 qaqc summary</SPAN>
select <SPAN class="operator token">=</SPAN> <SPAN class="string token">"HouseDir IS NULL OR StreetDir IS NULL"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"view"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"ADD_TO_SELECTION"</SPAN><SPAN class="punctuation token">,</SPAN>select <SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">if</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Describe<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"view"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>FIDSet <SPAN class="operator token">==</SPAN><SPAN class="string token">''</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">pass</SPAN>
<SPAN class="keyword token">elif</SPAN> int<SPAN class="punctuation token">(</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>Describe<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"view"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>FIDSet<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">>=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>Append_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"view"</SPAN><SPAN class="punctuation token">,</SPAN>temptable<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"NO_TEST"</SPAN><SPAN class="punctuation token">)</SPAN>
expression <SPAN class="operator token">=</SPAN> <SPAN class="string token">"HouseDir or StreetDir is null"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CalculateField_management<SPAN class="punctuation token">(</SPAN>temptable<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"ErrorType"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"'{}'"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>expression<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"PYTHON"</SPAN><SPAN class="punctuation token">)</SPAN>
outtable <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\Replicas\Replicas.gdb\Errors"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>Append_management<SPAN class="punctuation token">(</SPAN>temptable<SPAN class="punctuation token">,</SPAN>outtable<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"TEST"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>DeleteRows_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"tableinmemory"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"view"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"CLEAR_SELECTION"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>"view" in line 10 is a table view of a feature class created earlier; basically I have on table (view) that is of one schema and I need to copy selected records from it to my 'temptable' which has a different schema. Then I'm able to append records from temptable to an actual table in a real live gdb of the same schema. This whole piece of code works marvelously, and I repeat several times collecting various data entry errors if they exist. But...
I need to get rid of the tableinmemory, and can't seem to figure out a way to do so. From the python window in ArcMap I run this code:
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> <SPAN class="keyword token">if</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Exists<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"in_memory\\tableinmemory"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN> <SPAN class="keyword token">print</SPAN> <SPAN class="string token">"trying to delete"</SPAN>
<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Delete_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"tableinmemory"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Exists<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"in_memory\\tableinmemory"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN>
trying to delete
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
But notice after my printed 'trying to delete' there is no indication of TRUE as to whether or not line 4 successfully runs. However, in the geoprocessing/results I see this warning:
!WARNING 00010:tableinmemory does not exist
Okay, that's cool. I guess. But when I then try to run the code in the top window, I get:
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN>
Traceback <SPAN class="punctuation token">(</SPAN>most recent call last<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
File <SPAN class="string token">"C:\Users\JBorgione\AppData\Local\ESRI\Desktop10.5\AssemblyCache\{7A2884A1-0732-4438-A865-0C69929F369F}\QAQC_addin.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">23</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> onClick
temptable <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>CreateTable_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"in_memory"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"tableinmemory"</SPAN><SPAN class="punctuation token">,</SPAN>template<SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\management.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">17411</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> CreateTable
<SPAN class="keyword token">raise</SPAN> e
ExecuteError<SPAN class="punctuation token">:</SPAN> ERROR <SPAN class="number token">000258</SPAN><SPAN class="punctuation token">:</SPAN> Output in_memory\tableinmemory already exists
Failed to execute <SPAN class="punctuation token">(</SPAN>CreateTable<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>I have another module in which I create a simple polygon feature in memory, and I get rid of it like this:
<SPAN class="keyword token">for</SPAN> lyr <SPAN class="keyword token">in</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>ListLayers<SPAN class="punctuation token">(</SPAN>mxd<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> df<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> lyr<SPAN class="punctuation token">.</SPAN>name <SPAN class="operator token">==</SPAN> <SPAN class="string token">"ExtentPoly"</SPAN><SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>RemoveLayer<SPAN class="punctuation token">(</SPAN>df<SPAN class="punctuation token">,</SPAN>lyr<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>Delete_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"in_memory"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I've tried this approach as well for tableinmemory but to no avail. In fact, in a python window if I try to delete it, it still shows up as an option, even though its gone from the TOC, and I've deleted workspace in_memory:

So how does one really, really, really, delete a table in memory without closing down arcmap?
Having read Joshua Bixby 's timely series beginning with: /blogs/tilting/2014/08/01/when-inmemory-doesnt-mean-in-memory I realize I'm not the first, and probably not the last to find him/herself in this conundrum. (However, I did create a new tag that is a catch all....)