Getting "A FRenderResource was deleted without being released first!" Error

Hi I’m saving the modified skeleton mesh at the runtime. It goes well during saving the package but that error is occurred and that error is related to the ~FDuplicatedVerticesBuffer(). How can I solve this error?

Here is the code, log output and call stack:
code:

void FPersonaMeshDetails::UpdateMeshAsset(USkeletalMesh* TargetMesh, FString PackagePath)
{
	FString DestRelFilename = FPackageName::LongPackageNameToFilename(PackagePath, ".uasset");
	FString DestAbsFilename = FPaths::ConvertRelativePathToFull(DestRelFilename);
	FPaths::MakePlatformFilename(DestAbsFilename);

	TargetMesh->GetResourceForRendering()->ReleaseResources();
	TargetMesh->FlushRenderState();
	TargetMesh->ReleaseResources();

	TargetMesh->PostInitProperties();
	TargetMesh->PostEditUndo();
	TargetMesh->MarkPackageDirty();
	
	UPackage::Save(TargetMesh->GetOutermost(),nullptr,RF_Standalone,*DestRelFilename);
}

Log output:

[2020.08.21-09.43.02:760][ 36]LogSavePackage: Moving '../../../ArenaBattle/Saved/Shinbi1CE9D3F95472DA6044C4C1CBFAEC16F19.tmp' to '../../../ArenaBattle/Content/TestingArea/Shinbi1.uasset'
[2020.08.21-09.43.02:873][ 36]AssetCheck: New page: Asset Save: Shinbi1
[2020.08.21-09.43.02:873][ 36]LogContentValidation: Display: SkeletalMesh /Game/TestingArea/Shinbi1.Shinbi1 유효성 검사
[2020.08.21-09.43.08:986][ 36]LogOutputDevice: Warning: 

Script Stack (0 frames):

Fatal error: [File:E:/MyProjects/Vertex Modifier/UE4/Engine/Source/Runtime/RenderCore/Private/RenderResource.cpp] [Line: 193] 
A FRenderResource was deleted without being released first!
UE4Editor-Win64-Debug.exe has triggered a breakpoint.

call stack:
310897-

1 Like