Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

TSubclassOf cause access violation crash in shipping package


I don't know if my problem is really an Unreal bug but the behavior is quite strange and may be unexpected, so I share it with you in bug reports section in cas of.

I use TSubclassOf<> in a TArray for an inventory. It works in editor but often crash in shipping package when I try to access default object where it should not (all checks are here).

   // Array definition
   TArray<TSubclassOf<AMETA_Seed>> m_SeedSubclassArray;


    TSubclassOf<AMETA_Seed> seedSubclass;

     for (int32 i = 0; i < m_SeedSubclassArray.Num(); i++)
         seedSubclass = m_SeedSubclassArray[i];
         if (seedSubclass != nullptr && seedSubclass->IsValidLowLevel())
                     // Crash here
             seedDefaultObject = seedSubclass->GetDefaultObject<AMETA_Seed>();

I'm just thinking about UPROPERTY on TArray, it may be a garbage collector problem, as is seems pointers are behind TSubclassOf. In this case, I don't know if this beavior is unexpected or if it's just not evident. I will search in this way and post I'm finding any clue.

Someone has any idea of what can be wrong with this ?

Product Version: UE 4.12
more ▼

asked Oct 23 '16 at 12:44 PM in Bug Reports

avatar image

100 8 12 19

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Seems it is a garbage collection problem, for the moment I stop crashing in my shipping package. So TArrayof UObject derived class needs UPROPERTY macro to avoid undesirable behaviors like this.

The garbage collection overview doc may not be clear on this point:

The only container that is safe to have UObject or UObject-derived pointers in is a TArray

more ▼

answered Oct 24 '16 at 12:40 PM

avatar image

100 8 12 19

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question