Download

How to free memory in Editor?

Hi! I am importing textures in a batch like this:

This eventually fills up all the memory and crashes. I am even running it in a loop, saving after each 10 texture, making pause, running World->ForceGarbageCollect(true) - no effect. Until I restart Editor, memory just fills up with every new imported texture.
Any hints on this one? I suspect there is some handy hidden editor function to clean up all those textures stored in memory after the import, just can not track it down.

What/How are you saving? The default save (e.g. ctrl+s) only saves the map. A “Save all” (ctrl+shift+s) usually saves all assets to disk. Newly imported assets don’t seem to be automatically saved to disk.
In my editor plugin I’m using the following code to save all unsaved assets ( these are marked with a small * inside their icon/preview image in the asset browser ) after running a similiar automated import.
Maybe this removes the textures from memory after they were saved to disk.



	TArray<UPackage*> DirtyPackages;
	FEditorFileUtils::GetDirtyContentPackages(DirtyPackages);

	for (int32 PackageIndex = 0; PackageIndex < DirtyPackages.Num(); ++PackageIndex)
	{
		UPackage* PackageToSave = DirtyPackages[PackageIndex];
		FString PackageFilename = SourceControlHelpers::PackageFilename(PackageToSave);
		GEditor->SavePackage(PackageToSave, nullptr, RF_Standalone, *PackageFilename, nullptr);
	}


I am using this code, which is similar to yours:

Does not seem like it removes any assets from the memory;