janetsc commented on code in PR #13028: URL: https://github.com/apache/tvm/pull/13028#discussion_r992787060
########## src/runtime/hexagon/hexagon_device_api.cc: ########## @@ -115,13 +118,37 @@ void* HexagonDeviceAPI::AllocDataSpace(Device dev, size_t nbytes, size_t alignme if (alignment < kHexagonAllocAlignment) { alignment = kHexagonAllocAlignment; } - return mgr->AllocateHexagonBuffer(nbytes, alignment, String("global")); + CHECK(runtime_hexbuffs) << "runtime_hexbuffs is not initalized"; + return runtime_hexbuffs->AllocateHexagonBuffer(nbytes, alignment, String("global")); } void HexagonDeviceAPI::FreeDataSpace(Device dev, void* ptr) { CHECK(ptr) << "buffer pointer is null"; CHECK(IsValidDevice(dev)) << "dev.device_type: " << dev.device_type; - mgr->FreeHexagonBuffer(ptr); + if (runtime_hexbuffs) { + runtime_hexbuffs->FreeHexagonBuffer(ptr); + } else { + LOG(INFO) << "FreeDataSpace called when runtime_hexbuffs is not initialized"; Review Comment: This is not an error condition, per se, as this can happen if clients that allocated memory free their buffers on shutdown. Since this happens as part of process shutdown, it is ok that we've already freed the memory. One thing I could do is keep track of the buffers that were freed in ReleaseResources, and make sure this is one of those pointers. I also had it log a message using LOG instead of DLOG, because I want it to be visible when we "leak" memory at the end of a session. Ideally, these should all be freed before the session ends, and ReleaseResources() is called from the RPC client. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org