OccViewManager::instance()->myContext()->Erase(dim, Standard_True);
OccViewManager::instance()->myContext()->Remove(dim, Standard_True);
OccViewManager::instance()->myContext()->Update(dim, Standard_True);
dim->DimensionAspect().Nullify();
dim.Nullify();
Standard::Purge();
Here you need to call only OccViewManager::instance()->myContext()->Remove(dim, false), everything else is redundant and looks suspicious. Calling ::Update() for removed object certainly looks wrong.
AIS_InteractiveContext::Erase() hides presentation but keeps it in Context for fast redisplay, while AIS_InteractiveContext::Remove() completely removes it from Context (visual effect should be the same, the difference is either you want to redisplay object later or want to abandon it completely).
OccViewManager::instance()->myContext()->UpdateCurrentViewer();
OccViewManager::instance()->myContext()->CurrentViewer()->Redraw();
These two lines do (almost) the same thing, hence only one should be left (::UpdateCurrentViewer() for example).
If you are using AIS_ViewController (preferred), then you better call AIS_ViewController::FlushViewEvents() instead.
Note that the last boolean flag in AIS_InteractiveContext::Remove()/::Erase()/::Display() methods is to update the viewer.\
You should pass FALSE there if you call AIS_InteractiveContext::UpdateCurrentViewer() afterwards, otherwise you are redrawing viewer redundantly multiple times.