Questions in topic: "gc"https://answers.unrealengine.com/questions/topics/single/163736.html
The latest questions for the topic "gc"non-UPROPERTY UObject garbage collection.https://answers.unrealengine.com/questions/855673/non-uproperty-uobject-garbage-collection.html
Hi, I am new to UE and C++, By what I understood from c++ [intro page][1] , UObjects which are not marked with UPROPERTY will get GCed. here is the ScreenShot of the page.
![alt text][2]
I wrote one experiment code to understand this which looks like this:
UPROPERTY()
UObject *obj1;
UObject *obj2;
float time;
// Sets default values for this component's properties
UWaveActor::UWaveActor()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
obj1 = NewObject<UObject>();
obj2 = NewObject<UObject>();
// ...
}
// Called every frame
void UWaveActor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
if (obj2 != nullptr)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
AActor *ad = GetOwner();
FVector pos = ad->GetActorLocation();
time += DeltaTime;
pos.Z = FMath::Sin(time)*5.0f;
ad->SetActorLocation(pos);
}
}
and called GEngine->ForceGarbageCollection(true) from another actor component, which should destroy obj2 but the actor is still animating so obj2 is not destroyed. I misunderstood something or missing something, any help will be appreciated.
[1]: https://docs.unrealengine.com/en-US/Programming/Introduction
[2]: /storage/temp/261600-gc.pngc++ programminggarbage collectiongcFri, 07 Dec 2018 20:07:21 GMTYash.KansagaraEnsure condition failed: !IsGarbageCollecting()https://answers.unrealengine.com/questions/830598/ensure-condition-failed-isgarbagecollecting.html
This problem come from this:
There have two widget bp. A is main. B is a element in main. I drag some element from Palette to canvas to design a UI by UMG. The A was. when i'm working, maybe time's up. Something happened. Maybe auto store or other i don't known.
Them red error output into Output log window.
Here is stack.
Error: === Handled ensure: ===
Error: Ensure condition failed: !IsGarbageCollecting() [File:D:\UnrealEngine-4.20.1-release\Engine\Source\Runtime\UMG\Private\Slate\SObjectWidget.cpp] [Line: 41]
Error: SObjectWidget for 'ScrollBackgroundPanelWidget_C /Engine/Transient.World_1:MobileBag_C_2.WidgetTree_0.NealScrollBar' destroyed while collecting garbage. This can lead to multiple GCs being required to cleanup the object. Possible causes might be,
Error: 1) ReleaseSlateResources not being implemented for the owner of this pointer.
Error: 2) You may just be holding onto some slate pointers on an actor that don't get reset until the actor is Garbage Collected. You should avoid doing this, and instead reset those references when the actor is Destroyed.
Error: Stack:
Error: [Callstack] 0x00007ffecccf8e16 UE4Editor-Core.dll!FWindowsPlatformStackWalk::StackWalkAndDump() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\private\windows\windowsplatformstackwalk.cpp:235]
Error: [Callstack] 0x00007ffecca4f082 UE4Editor-Core.dll!FDebug::EnsureFailed() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\private\misc\assertionmacros.cpp:305]
Error: [Callstack] 0x00007ffecca67de6 UE4Editor-Core.dll!FDebug::OptionallyLogFormattedEnsureMessageReturningFalseImpl() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\private\misc\assertionmacros.cpp:436]
Error: [Callstack] 0x00007ffecb0980a3 UE4Editor-UMG.dll!SObjectWidget::~SObjectWidget() [d:\unrealengine-4.20.1-release\engine\source\runtime\umg\private\slate\sobjectwidget.cpp:41]
Error: [Callstack] 0x00007ffecbbb53b3 UE4Editor-SlateCore.dll!TIndirectArray<SBoxPanel::FSlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:434]
Error: [Callstack] 0x00007ffecbb5c1b3 UE4Editor-SlateCore.dll!SBoxPanel::~SBoxPanel() []
Error: [Callstack] 0x00007ffecbbb52de UE4Editor-SlateCore.dll!TIndirectArray<SOverlay::FOverlaySlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:434]
Error: [Callstack] 0x00007ffecbb5c3a3 UE4Editor-SlateCore.dll!SOverlay::~SOverlay() []
Error: [Callstack] 0x00007ffecbbb53b3 UE4Editor-SlateCore.dll!TIndirectArray<SBoxPanel::FSlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:434]
Error: [Callstack] 0x00007ffecbb5c1b3 UE4Editor-SlateCore.dll!SBoxPanel::~SBoxPanel() []
Error: [Callstack] 0x00007ffecbbb52de UE4Editor-SlateCore.dll!TIndirectArray<SOverlay::FOverlaySlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:434]
Error: [Callstack] 0x00007ffecbb5c3a3 UE4Editor-SlateCore.dll!SOverlay::~SOverlay() []
Error: [Callstack] 0x00007ffecbb5b4aa UE4Editor-SlateCore.dll!FSlotBase::~FSlotBase() [d:\unrealengine-4.20.1-release\engine\source\runtime\slatecore\private\slotbase.cpp:77]
Error: [Callstack] 0x00007ffecc0c24d2 UE4Editor-Slate.dll!TIndirectArray<SConstraintCanvas::FSlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:435]
Error: [Callstack] 0x00007ffecc099dac UE4Editor-Slate.dll!SConstraintCanvas::~SConstraintCanvas() []
Error: [Callstack] 0x00007ffecbbb52de UE4Editor-SlateCore.dll!TIndirectArray<SOverlay::FOverlaySlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:434]
Error: [Callstack] 0x00007ffecbb5c3a3 UE4Editor-SlateCore.dll!SOverlay::~SOverlay() []
Error: [Callstack] 0x00007ffecbb5b4aa UE4Editor-SlateCore.dll!FSlotBase::~FSlotBase() [d:\unrealengine-4.20.1-release\engine\source\runtime\slatecore\private\slotbase.cpp:77]
Error: [Callstack] 0x00007ffecc0c24d2 UE4Editor-Slate.dll!TIndirectArray<SConstraintCanvas::FSlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:435]
Error: [Callstack] 0x00007ffecc099dac UE4Editor-Slate.dll!SConstraintCanvas::~SConstraintCanvas() []
Error: [Callstack] 0x00007ffecb152a7b UE4Editor-UMG.dll!UCanvasPanel::ReleaseSlateResources() [d:\unrealengine-4.20.1-release\engine\source\runtime\umg\private\components\canvaspanel.cpp:25]
Error: [Callstack] 0x00007ffecdce050f UE4Editor-CoreUObject.dll!UObject::ConditionalBeginDestroy() [d:\unrealengine-4.20.1-release\engine\source\runtime\coreuobject\private\uobject\obj.cpp:901]
Error: [Callstack] 0x00007ffecdcb4176 UE4Editor-CoreUObject.dll!UnhashUnreachableObjects() [d:\unrealengine-4.20.1-release\engine\source\runtime\coreuobject\private\uobject\garbagecollection.cpp:1625]
Error: [Callstack] 0x00007ffecdc36afe UE4Editor-CoreUObject.dll!CollectGarbageInternal() [d:\unrealengine-4.20.1-release\engine\source\runtime\coreuobject\private\uobject\garbagecollection.cpp:1576]
Error: [Callstack] 0x00007ffecdc35e7e UE4Editor-CoreUObject.dll!CollectGarbage() [d:\unrealengine-4.20.1-release\engine\source\runtime\coreuobject\private\uobject\garbagecollection.cpp:1656]
Error: [Callstack] 0x00007ffec220f4b2 UE4Editor-UnrealEd.dll!FEditorFileUtils::AutosaveMapEx() [d:\unrealengine-4.20.1-release\engine\source\editor\unrealed\private\filehelpers.cpp:2507]
Error: [Callstack] 0x00007ffec24886bb UE4Editor-UnrealEd.dll!FPackageAutoSaver::AttemptAutoSave() [d:\unrealengine-4.20.1-release\engine\source\editor\unrealed\private\packageautosaver.cpp:195]
Error: [Callstack] 0x00007ffec27e2691 UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick() [d:\unrealengine-4.20.1-release\engine\source\editor\unrealed\private\unrealedengine.cpp:431]
Error: [Callstack] 0x00007ff7d93c5c0d UE4Editor.exe!FEngineLoop::Tick() [d:\unrealengine-4.20.1-release\engine\source\runtime\launch\private\launchengineloop.cpp:3495]
Error: [Callstack] 0x00007ff7d93d6aa0 UE4Editor.exe!GuardedMain() [d:\unrealengine-4.20.1-release\engine\source\runtime\launch\private\launch.cpp:166]
Error: [Callstack] 0x00007ff7d93d6b1a UE4Editor.exe!GuardedMainWrapper() [d:\unrealengine-4.20.1-release\engine\source\runtime\launch\private\windows\launchwindows.cpp:144]
Error: [Callstack] 0x00007ff7d93e3ef7 UE4Editor.exe!WinMain() [d:\unrealengine-4.20.1-release\engine\source\runtime\launch\private\windows\launchwindows.cpp:223]
Error: [Callstack] 0x00007ff7d93e5957 UE4Editor.exe!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253]
Error: [Callstack] 0x00007ffef3d73034 KERNEL32.DLL!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffef6771461 ntdll.dll!UnknownFunction []
The detail process is i'm making a UI by UMG. I create a new widget and drag some Common element into. Them i drag some "User Created" element into. All of them are old and has used in other widget and fine.
Now i have lots of element in my new widget and some of them are default from editor, others are old and in using.
The old not just one. But after shoot time. error come in.
I don't known how it happen.
It's strange.
1. All i used widget has used into other widget and fine.
2. The error one create by right menu and inherit from User Widget. ReleaseSlateResource has implemented.
3. The error one didn't dynamically create. How to reset it when gc?
Widget structure like this
![alt text][1]
So, how to solve it. I had encounter it in two widget.
My environment is Win10 enterprise, 4.20.1 source code.
[1]: /storage/temp/254388-question.pnggcSat, 22 Sep 2018 04:31:02 GMT0xcdafd0f1[4.20] Engine Crash on GC cleanup after stopped PIEhttps://answers.unrealengine.com/questions/812854/420-engine-crash-on-gc-cleanup-after-stopped-pie.html
Hey there,
After upgrading to 4.20 i've discovered a crash that happens everytime.
**Replication steps:**
- Create a new blueprint First Person Template project
- Create a new Default level and save it
- Add the FirstPersonExample map as a sub level and set the option Initially Loaded as true but leave the Initally Visible as false (if you set it to true it doesn't crash)
- Run the game and as soon as you press ESC to stop it will crash when trying to clear the GC on UEditorEngine::EndPlayMap from the PlayLevel.cpp.
**The overall crash is:** Everytime you have a sub level with Initially Loaded set to true and Initially Visible set to false it will always crash on stop PIE.
**Crashdump:**
LoginId:ffb8a20c48f1d79df4976cb3193ef28f
EpicAccountId:aec39bec4f81450ea55941698b4d8e4f
Fatal error: [File:D:\Build\++UE4\Sync\Engine\Source\Developer\MessageLog\Private\Model\MessageLogListingModel.cpp] [Line: 81] MetaData /Game/FirstPersonBP/Maps/UEDPIE_0_FirstPersonExampleMap.PackageMetaData Object from PIE level still referenced. Shortest path from root: MetaData /Game/FirstPersonBP/Maps/UEDPIE_0_FirstPersonExampleMap.PackageMetaData [target] (standalone)
UE4Editor_Core!FDebug::AssertFailed() [d:\build\++ue4\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:425]
UE4Editor_Core!FMsg::LogfImpl() [d:\build\++ue4\sync\engine\source\runtime\core\private\logging\logmacros.cpp:64]
UE4Editor_MessageLog!FMessageLogListingModel::AddMessageInternal() [d:\build\++ue4\sync\engine\source\developer\messagelog\private\model\messageloglistingmodel.cpp:81]
UE4Editor_MessageLog!FMessageLogListingViewModel::AddMessages() [d:\build\++ue4\sync\engine\source\developer\messagelog\private\presentation\messageloglistingviewmodel.cpp:156]
UE4Editor_Core!FMessageLog::Flush() [d:\build\++ue4\sync\engine\source\runtime\core\private\logging\messagelog.cpp:198]
UE4Editor_Core!FMessageLog::~FMessageLog() [d:\build\++ue4\sync\engine\source\runtime\core\private\logging\messagelog.cpp:95]
**UE4Editor_UnrealEd!UEditorEngine::EndPlayMap() [d:\build\++ue4\sync\engine\source\editor\unrealed\private\playlevel.cpp:490]**
UE4Editor_UnrealEd!UEditorEngine::Tick() [d:\build\++ue4\sync\engine\source\editor\unrealed\private\editorengine.cpp:1957]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [d:\build\++ue4\sync\engine\source\editor\unrealed\private\unrealedengine.cpp:403]
UE4Editor!FEngineLoop::Tick() [d:\build\++ue4\sync\engine\source\runtime\launch\private\launchengineloop.cpp:3495]
UE4Editor!GuardedMain() [d:\build\++ue4\sync\engine\source\runtime\launch\private\launch.cpp:166]
UE4Editor!GuardedMainWrapper() [d:\build\++ue4\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:144]
UE4Editor!WinMain() [d:\build\++ue4\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:223]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283]
kernel32
ntdllcrashpiegarbage collectorgcSat, 28 Jul 2018 15:51:38 GMTxlar8orGC & UPROPERTY, working with CreateDefaultSubobject / NewObjecthttps://answers.unrealengine.com/questions/714563/gc-uproperty-working-with-createdefaultsubobject-n.html
Hi there,
I'm studying GC system of UE4, and get confused with some concept.
As official wiki and docs mentioned, UObject will be held and kept IF there is a UPROPERTY() class member refereced that. So,
(1) Seems that creating subcomps with ***CreateDefaultSubobject<>() does not required a UPROPERTY() ptrs*** to save them. Is that mean "*Parent actor has already kept references somewhere*"? Or some other reasons?
(2) If I create a component dynamically with ***NewObject<>() without saving it in a UPROPERTY() var***, but then call RegisterComponent() immediately, IS IT A LEGAL WAY to use NewObject<>()?
(3) NewObject<>(this) , with the semantic of "DECLARED this AS OUTER", seems just like what CreateDefaultSubobject<>() does. But NewObject<>() requires that u have to EXPLICITLY declare some kind of "relationship" between the outer object and new object. So **what makes them different, NewObject and CreateDefaultSubobject?**
Since i'm pretty newbie to UE4, questions may be a little bit stupid...Any answer or comment will be much apprieciated!!
Joyahc++upropertygcWed, 11 Oct 2017 09:14:04 GMTJoyahVariable UObject invalid after starthttps://answers.unrealengine.com/questions/709385/variable-uobject-invalid-after-start.html
I have a class derived from a UObject defined like this
UCLASS()
class MYPROJECT_API UStatistics : public UObject
It has private members and public function to access these members. Every function is a UFUNCTION, so that I can call them inside the blueprint.
I have an instance of this class inside another class, defined as follow
UCLASS()
class MYPROJECT_API AFirstPlayer : public ACharacter
{
[...]
public:
UPROPERTY(BlueprintReadOnly)
UStatistics* Statistics;
}
In the costructor I initialize this variable as follow
Statistics = CreateDefaultSubobject<UStatistics>(TEXT("Statistics"));
I created a blueprint from my AFirstPlayer C++ class, but if in the event graph I try to use the Statistics variable, it says that it is invalid. What am I missing? Am I forced to setup an attachment for these variable?c++blueprintgcSun, 24 Sep 2017 15:10:58 GMTastinogHow do I correctly use pointers in this situation?https://answers.unrealengine.com/questions/700645/how-do-i-correctly-use-pointers-in-this-situation.html
Hello.
I'm desperately trying to remember C++ right now and I have stumbled across this problem.
I'm trying to deserealize data from JSON for which I am using UE4 libraries.
Consider the signature for the `FJsonObject::TryGetArrayField` method that I am trying to use:
bool TryGetArrayField
(
const FString & FieldName,
const TArray < TSharedPtr < FJsonValue > > *& OutArray
)
This code works if I pass a variable declared as `const TArray<TSharedPtr<FJsonValue>> *OutArray` as the second parameter, but leaves me wondering about 2 things:
1) Isn't there a better way to use pointers in case of "OutArray" variable? Can I avoid using the native const "*" pointer here and use a smart pointer instead? Using `TSharedPtr<TArray<TSharedPtr<FJsonValue>>> OutArray` gives me compile time errors about assigning temporary object to a reference.
2) Why does trying to delete "OutArray" pointer later on gives me an exception at runtime? Does that mean UE4's GC manages this pointer for me? How can I be aware if data reference by "*" pointer is managed by GC if it's not an explicit "UPROPERTY()"?.
Thanks in advance.c++c++ programmingmemorypointergcMon, 28 Aug 2017 12:05:04 GMTglen-vWill GC run while automation testinghttps://answers.unrealengine.com/questions/658405/will-gc-run-while-automation-testing.html
Given the following code, is MyObj_1 visible to the Garbage Collector?
Meaning, it will be collected the moment the GC does collection.
And, do GC collections happen while automation testing?
bool FTestProjectTest::RunTest(
FString const & Parameters
)
{
{
auto * MyObj_1 = NewObject<UMyClass>();
UPROPERTY()
auto * MyObj_2 = NewObject<UMyClass>();
// ...
// use UObjects
}
return true;
}c++upropertyautomated testinggcWed, 14 Jun 2017 21:55:04 GMTdlo_olbSuperfluous nullptr check?https://answers.unrealengine.com/questions/597683/superfluous-nullptr-check.html
I saw the following code in PaperSprite.cpp
Maybe I am totally missing something, but how can the check (BodySetup == nullptr) ever fail?
I know it is a GC system, but I don't even see a reason to first set it to nullptr.. NewObject sets the value anyways.
I ask this mostly to see whether my understanding of the GC is correct :)
void UPaperSprite::RebuildCollisionData()
{
UBodySetup* OldBodySetup = BodySetup;
// Ensure we have the data structure for the desired collision method
switch (SpriteCollisionDomain)
{
case ESpriteCollisionMode::Use3DPhysics:
BodySetup = nullptr;
if (BodySetup == nullptr)
{
BodySetup = NewObject<UBodySetup>(this);
}
break;c++null pointergcMon, 08 May 2017 01:28:13 GMTdlo_olbUObject outer and GChttps://answers.unrealengine.com/questions/570044/uobject-outer-and-gc.html
I'm trying to understand what an UObject's 'outer' really means, and how it affects GC. From my understanding, the only GC guarantee seems to be:
* If you store UObject A pointer as a member of UObject B, and mark it as a UPROPERTY, that UObject A will stay alive as long as UObject B is alive
What I'm trying to understand is what effect the UObject's 'outer' actually has regarding GC. I was having some issues where:
* UObject A gets created using NewObject(this) in some function inside UObject B, and used as a local scope varible (not a member)
* When the game finishes, the GC runs and ensures everything is cleaned up
* It goes through all UObjects and runs some code that, in between other things, tries to find each UObject's outermost UObject
* There's a crash -> UObject A has it's outer set to an invalid (already deleted) UObject
So it seems that even though we set B as the outer of A, there isn't a guarantee that A will be deleted before B, and the cleanup check will fail as it can't find A's outer. So what does 'outer' actually do?
What we were trying to accomplish was the creation of local scope UObjects. We seem to have fixed it by not specifying the outer, and letting it default to GetTransientPackage() - however, without fully understanding what TransientPackage is, I don't feel like this is a proper fix and might just be working by luck in the GC run order.
Any clarification or help would be appreciated :)c++garbage collectorgarbage collectionnewobjectgcWed, 01 Mar 2017 17:10:22 GMTjPinhaoParticle system material garbage collectedhttps://answers.unrealengine.com/questions/529461/particle-system-material-garbage-collected.html
Hello,
There has been a very annoying bug in the packaged version of my game where it would occasionally crash due to random particle system component related code. Today I luckily ran into the crash while debugging (DebugGame config) and got a helpful crash log. The output informed me that a material of a particle system required module was invalid.
So I figured the reason for this must be that the material is garbage collected for some reason. I am dynamically loading the particle system during the game with this code:
// Some code
static UParticleSystem * ExplosionEmitter = UBrickGameInstance::SynchronousLoad<UParticleSystem>("ParticleSystem'/Game/BrickRigs/ParticleFX/Fire/P_Explosion.P_Explosion'");
Loading function:
template<>
inline UParticleSystem * UBrickGameInstance::SynchronousLoad(const FString & AssetPath)
{
// Inside the loading function
UParticleSystem * ParticleSystem = LoadObject<UParticleSystem>(NULL, *AssetPath);
if (ParticleSystem)
{
ParticleSystem->AddToRoot();
}
return ParticleSystem;
}
So I added this code as a workaround and it seems to have fixed the issue:
for (UParticleEmitter * Emitter : ParticleSystem->Emitters)
{
for (UParticleLODLevel * LODLevel : Emitter->LODLevels)
{
if (LODLevel->RequiredModule->Material)
{
LODLevel->RequiredModule->Material->AddToRoot();
}
}
}
Although the workaround seems to be working, it's not a nice solution so I would be glad to hear the reason why it didn't not work in the first place. Am I missing something? Shouldn't it be enough to add the particle system to the root?c++gcSun, 27 Nov 2016 20:03:53 GMTFluppi393Crash occured when invoke AddToRoot and AddToViewport at one timehttps://answers.unrealengine.com/questions/509118/crash-occured-when-invoke-addtoroot-and-addtoviewp.html
code to reproduce issue:
UUserWidget* Widget = CreateWidget<UUserWidget>(MyPlayerController, WidgetTemplate);
if (Widget)
{
Widget->AddToRoot();
Widget->AddToViewport();
}
If invoke **AddToRoot** and **AddToViewport** at the same time, UE4Editor would crash when click **Stop** button
of Editor at runtime.
crash dump:
Assertion failed: !IsRooted() [File:d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\coreuobject\public\uobject\UObjectBaseUtility.h] [Line: 135]
UE4Editor_Core!FDebug::AssertFailed() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\core\private\misc\outputdevice.cpp:421]
UE4Editor_UnrealEd!<lambda_26419e543909ee92ebfb672b1e9c08dc>::operator()() [d:\build\++ue4+release-4.13+compile\sync\engine\source\editor\unrealed\private\playlevel.cpp:384]
UE4Editor_CoreUObject!ForEachObjectWithOuter() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\coreuobject\private\uobject\uobjecthash.cpp:678]
UE4Editor_UnrealEd!UEditorEngine::EndPlayMap() [d:\build\++ue4+release-4.13+compile\sync\engine\source\editor\unrealed\private\playlevel.cpp:380]
UE4Editor_UnrealEd!UEditorEngine::Tick() [d:\build\++ue4+release-4.13+compile\sync\engine\source\editor\unrealed\private\editorengine.cpp:1653]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [d:\build\++ue4+release-4.13+compile\sync\engine\source\editor\unrealed\private\unrealedengine.cpp:371]
UE4Editor!FEngineLoop::Tick() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\launch\private\launchengineloop.cpp:2834]
UE4Editor!GuardedMain() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\launch\private\launch.cpp:156]
UE4Editor!GuardedMainWrapper() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]
kernel32
ntdll
I think UE4 should prevent users to invoke **AddToRoot** and **AddToViewport** at the same time, or give an exact tip to warn users from that usage.bug reportcrashwidgetgcTue, 18 Oct 2016 16:21:09 GMT笑傲江湖-DAPrevent garbage collecting, how to RemoveFromRoot ?https://answers.unrealengine.com/questions/505439/prevent-garbage-collecting-how-to-removefromroot.html
Hello,
I have a UObject class with different tools, access to it is through the static variable (DifferentMix), I can not use UPROPERTY().
So I use DifferentMix->AddToRoot(), it works, but **how to remove properly?** If I do not do it, when I stop simulation the engine crash.
I'm trying to delete it in the destructor, but the engine does not start then, I initialize variable in BeginPlay(), i need already world exist.
AClientCharacter::~AClientCharacter()
{
DifferentMix->RemoveFromRoot();
}
And how to use UObjectBaseUtility::AddToRoot / UObjectBaseUtility::RemoveFromRoot ? From this
question:
https://answers.unrealengine.com/questions/493997/best-way-to-avoid-uobjects-garbage-collection.htmlc++gcWed, 12 Oct 2016 16:56:33 GMTSyntopiaActors in PIE can't handle big TInlineAllocatorshttps://answers.unrealengine.com/questions/456878/actors-in-pie-cant-handle-big-tinlineallocators-1.html
I am currently trying to write cache friendly agent system. And I am not sure if this is a bug or works as intended but if I have an Actor placed on scene that consists of
TArray<FMainTask, TInlineAllocator<65536>> MainTask;
where FMainTask is
USTRUCT(BlueprintType, Blueprintable)
struct FMainTask
{
GENERATED_USTRUCT_BODY()
int64 as1;
int64 as12;
int64 as13;
int64 as14;
int64 as15;
};
Game will crash if I start it in PIE inside of UObjectProperty::EmitReferenceInfo. However if I start just the game from VS everything seems to work fine.
Is this a bug or am I missing something about about TInlineAllocator?
ps. Dropping numbers to ~16k in allocator or getting rid of it and spawning ~65k structs and adding to array works fine.arraypiegarbage collectorgcallocatorFri, 22 Jul 2016 14:22:15 GMTvebskiWhy doesn't my UObjects survive GC at compile?https://answers.unrealengine.com/questions/251705/why-doesnt-my-uobjects-survive-gc-at-compile.html
Hello,
I have a TArray of a UObject-derived class in an actor class I've written in code. The array is a UPROPERTY and the elements survive a restart of the editor. I create these objects and add them to the array in the editor by a Blutility method.
I've created a blueprint that derives from my actor to customize some of the default values. What happens is, if I have an instance of this blueprint in the level and populate the array, I can't compile that blueprint anymore because those elements in the array all become null. I've checked and they are there until the compile.
So, why do they get garbage collected when I compile the blueprint?
Thanks in advance,
Can Mertgccustom uobjectThu, 02 Jul 2015 17:12:33 GMTTalemonClarification about GC and NewObject<>https://answers.unrealengine.com/questions/212100/clarification-about-gc-and-newobject.html
I have a plugin module where the implementation class is derived from custom derivation of IModuleInterface. The module loads fine and is accessible. Inside the module implementation I have a private regular C++ pointer (not decorated with UPROPERTY because after all this class is a module class and not an UObject) to a custom UObject. Inside StartupModule I allocate an instance of that object using NewObject<>.
Is this sufficient for keeping said private UObject alive? NewObject<> assigns a default Outer object, no? And so isn't that good enough to keep it alive from the GC? I test the persistence by calling GetWorld()->ForceGarbageCollection(true) inside my custom PlayerController in the main game module repeatedly through a triggered UFUNCTION, and the UObject in question seems to stay accessible. I am just getting lucky or is what I am doing legit?c++newobjectmemory managementgcWed, 15 Apr 2015 03:33:29 GMTdekratTArray not properly garbage collected?https://answers.unrealengine.com/questions/206724/tarray-not-properly-garbage-collected.html
I have the following code in my blueprint based on AActor.
UPROPERTY()
UHierarchicalInstancedStaticMeshComponent* MeshComponent;
UPROPERTY()
TArray<UHierarchicalInstancedStaticMeshComponent*> MeshComponents;
In the first one I store all my instances and GC works fine.
If I divide my instances into separate components that I've added to MeshComponents it seems I get no GC, and every new run with "New editor window" causes more memory usage and less fps.
Works: MeshComponent with 100.000 instances
Doesn't work: TArray of 100 MeshComponents with 1000 instances each.blueprintsc++instanced static mesh componenttarraygcMon, 06 Apr 2015 10:53:06 GMThallatoreProper way to add a GC reference for a dynamically allocated UObjecthttps://answers.unrealengine.com/questions/179376/proper-way-to-add-a-gc-reference-for-a-dynamically.html
I have an editor viewport client that I am working on that dynamically creates some proxies for tabs. It can reference them through its own overridden AddReferencedObjects() call, but that precludes them being dynamically allocated as needed.
What's the proper way to reference them at runtime?c++editorgcFri, 27 Feb 2015 09:28:58 GMTBackovSlate crash when exiting PIE (SListView and GC)https://answers.unrealengine.com/questions/163737/slate-crash-when-exiting-pie-slistview-and-gc.html
Hi,
When I close my game in PIE while a SListView is visible on screen., the editor freezes for a second or two then crashes.
UE4Editor-CoreUObject.dll!UObjectBase::IsValidLowLevelFast(bool bRecursive) Line 306 C++
UE4Editor-CoreUObject.dll!UObjectBase::IsValidLowLevelFast(bool bRecursive) Line 320 C++
UE4Editor-CoreUObject.dll!FGCCollector::HandleObjectReference(UObject * & Object, const UObject * ReferencingObject, const UObject * ReferencingProperty) Line 268 C++
UE4Editor-Flare.dll!TListTypeTraits<IFlareShipInterface * __ptr64>::AddReferencedObjects(FReferenceCollector & Collector, TArray<IFlareShipInterface *,FDefaultAllocator> & ItemsWithGeneratedWidgets, TSet<IFlareShipInterface *,DefaultKeyFuncs<IFlareShipInterface *,0>,FDefaultSetAllocator> & SelectedItems) Line 214 C++
UE4Editor-CoreUObject.dll!UGCObjectReferencer::AddReferencedObjects(UObject * InThis, FReferenceCollector & Collector) Line 17 C++
UE4Editor-CoreUObject.dll!FArchiveRealtimeGC::ProcessObjectArray(TArray<UObject *,FDefaultAllocator> & InObjectsToSerializeArray, TRefCountPtr<FGraphEvent> & MyCompletionGraphEvent) Line 706 C++
UE4Editor-CoreUObject.dll!TGraphTask<FArchiveRealtimeGC::FGCTask>::ExecuteTask(TArray<FBaseGraphTask *,FDefaultAllocator> & NewTasks, ENamedThreads::Type CurrentThread) Line 671 C++
UE4Editor-Core.dll!FTaskThread::ProcessTasks(int QueueIndex, bool bAllowStall) Line 428 C++
UE4Editor-Core.dll!FTaskThread::ProcessTasksUntilQuit(int QueueIndex) Line 271 C++
UE4Editor-Core.dll!FTaskThread::Run() Line 562 C++
UE4Editor-Core.dll!FRunnableThreadWin::Run() Line 73 C++
UE4Editor-Core.dll!FRunnableThreadWin::GuardedRun() Line 48 C++
[External Code]
Here is the code.
// Ship list
TSharedPtr< SListView<IFlareShipInterface*> > ShipList;
TArray<IFlareShipInterface*> ShipListData;
// Create the list
SAssignNew(ShipList, SListView<IFlareShipInterface*>)
.ListItemsSource(&ShipListData)
.SelectionMode(ESelectionMode::Single)
.OnGenerateRow(this, &SFlareSectorMenu::GenerateShipInfo)
// Fill the list
ShipListData.AddUnique(GetShipPawn());
ShipList->RequestListRefresh();
// Display callback
TSharedRef<ITableRow> SFlareSectorMenu::GenerateShipInfo(IFlareShipInterface* Item, const TSharedRef<STableViewBase>& OwnerTable)
{
AFlarePlayerController* PC = Cast<AFlarePlayerController>(OwnerHUD->GetOwner());
return SNew(STableRow<IFlareShipInterface*>, OwnerTable)
.Content()
[
SNew(STextBlock).Text(FText::FromString("Test"))
];
}
I believe something is wrong at low level with this code. The list itself is fine, it works and shows up as expected.
Thanks for helping !c++crashslategcslistviewSun, 25 Jan 2015 13:25:15 GMTStrangerGwenn