在ue4中,memreport -full时UE会自动触发GC,修改哪里的代码可以让ue在memreport 时不先触发gc
- User
在ue4中,memreport -full时UE会自动触发GC,修改哪里的代码可以让ue在memreport 时不先触发gc
- Assistant
要让UE在memreport时不触发自动GC,可以在UE的源代码中进行修改。具体的修改步骤如下:
- 打开UE的源代码文件夹。
- 导航到
Engine\Source\Runtime\Engine\Private\World.cpp文件。 - 在
void UWorld::HandleMemReportCommand(const TArray<FString>& Args, FOutputDevice& Ar)函数中找到以下行:
if (Args.Contains(TEXT("full"))) { // Force collection to get accurate mem report results UE_LOG(LogGarbage, Log, TEXT("Collecting garbage to get accurate memory report results...")); CollectGarbage(GARBAGE_COLLECTION_KEEPFLAGS); }- 将以上代码段注释掉或删除掉。
- 保存并编译UE的源代码。
- 重新启动UE编辑器,现在当您使用memreport -full命令时,UE将不会自动触发GC。
请注意,在修改UE的源代码之前一定要备份您的代码文件,以防止意外情况发生。
- User
在4.26的World.cpp没找到HandleMemReportCommand
- Assistant
很抱歉,如果在UE4.26版本中未找到
HandleMemReportCommand函数,那么可能是因为该函数被移动或重命名了。在这种情况下,您可以尝试在其他文件中查找处理memreport命令的代码。您可以尝试以下步骤:
- 打开UE4.26版本的源代码文件夹。
- 使用文本编辑器打开整个源代码文件夹,并使用搜索功能搜索
memreport关键字,看是否能找到相关的处理代码。 - 如果找到了包含
memreport处理的文件,请查看文件中的函数和逻辑,找到可能与自动触发GC相关的代码段,并注释或删除它。 - 保存并编译UE4.26的源代码。
- 重新启动UE编辑器,现在当使用
memreport -full命令时,应该不会自动触发GC。
请注意,在修改UE的源代码之前,请备份您的项目和代码文件,以防止意外情况的发生,并确保您了解您所做的更改可能会对引擎行为产生的影响。
- User
void UObject::AbortInsideMemberFunction() const { //put a trace of this in the log to help diagnostics at a glance. UE_LOG(LogObj, Warning, TEXT("UObject::AbortInsideMemberFunction called on object %s."), *GetFullName()); //a bit more ideally, we could set GIsCriticalError = true and call FPlatformMisc::RequestExit. however, not all platforms would generate a dump as a result of this. //as such, we commit an access violation right here. we explicitly want to avoid the standard platform error/AssertFailed paths as they are likely to pollute the //callstack. this in turn is more likely to prevent useful (e.g. this object) memory from making its way into a minidump.
//this'll result in the address of this object being conveniently loaded into a register, so we don't have to dig a pointer out of the stack in the event of any //ambiguity/reg-stomping resulting from the log call above. in a test ps4 minidump, this also ensured that the debugger was able to automatically find the address of //"this" within the stack frame, which was otherwise made impossible due to register reuse in the log call above. *GUObjectAbortNullPointer = this;} 在安卓执行gc时崩溃 在 *GUObjectAbortNullPointer = this;
- Assistant
*GUObjectAbortNullPointer = this;是UE4中的一段代码,用于在对象被标记为空指针时引发崩溃日志。在您的情况下,由于注释中提到的自动GC过程中发生崩溃,您可以尝试使用以下方法来解决问题:- 打开UE4的源代码文件夹。
- 导航到
Engine\Source\Runtime\Core\Private\UObject\UObjectBase.cpp文件。 - 找到
OBJ_FORCEINLINE void ForceCrashViaNullPointer()函数。 - 将以下行注释掉或删除掉:
*GUObjectAbortNullPointer = this;- 保存并编译UE4的源代码。
- 重新运行您的UE4项目,然后尝试执行GC,应该不会再发生崩溃。
请注意,在修改UE4的源代码之前,请备份您的项目和代码文件,以防止意外情况的发生,并确保您了解您所做的更改可能会对引擎行为产生的影响。
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.