DNM: implement object map for tracking used image objects

Branch based up wip-8902 branch (#2699). Unique commits start at 38ebaa7.
Not sure, maybe here we need to fallback to clear all object_map? It seemed corruption happened for object_map