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"

ArrayNum is larger than ArrayMax


When I play my game everything works fine for the first 30 seconds, then my inventory stops drawing and a few seconds later I get this error: http://gyazo.com/6be5584d47622ad604beacf7443026cf

Here's if you don't want to look at the screenshot:

 inventory    {AllocatorInstance={Data=0x000000416e4825c0 {...} } ArrayNum=20 ArrayMax=22 }    TArray<UItemStruct *,FDefaultAllocator>
 this    0x000000416e4b0100 {inventory={AllocatorInstance={Data=0x000000416e4825c0 {...} } ArrayNum=20 ArrayMax=...} ...}    AprojectcrusadeHUD *

Any ideas? I've tried null checking everything, but nothing works. :(

Product Version: Not Selected
more ▼

asked Feb 11 '15 at 04:10 PM in C++ Programming

avatar image

82 24 24 31

avatar image MickD777 Feb 11 '15 at 04:17 PM

You never verify that inventory[x]->slot[y] is valid, that could be your problem.

The other reason could be that for some reason you delete something in your array without removing that element. That would lead to the element in your array pointing at the adress with garbage in it.

avatar image Wrekk Feb 12 '15 at 11:27 AM

OK, I tried this:http://gyazo.com/7d5778b23820458c56c80e4bb08fb83f

But it gave me the exact same issue.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Your issues sounds to me as if it is related to garbage collection. Especially as you say that it is working fine for some time and it then is going to crash. To better help you I'd need to know how your array declaration looks like and how and what you add to it (UObject?). As I see in your screenshots the array is a TArray. A wild guess would be that you didn't mark it as managed by using UPROPERTY() in the declaration and it contains UObjects which aren't referenced from somewhere else.

Hope this helps and if not please provide more informations.

Best, Eckhard

more ▼

answered Feb 12 '15 at 12:41 PM

avatar image

240 10 6 13

avatar image Wrekk Feb 12 '15 at 01:06 PM

My .cpp file: http://tny.cz/97812111

My .h file: http://tny.cz/631d23c6

If you need the other scripts as well, please tell me. :)

EDIT: I fixed it, I think. I moved stuff from my ItemList script which was all static variables and functions without uproperty etc. to my HUD script, and added uproperty to everything.

avatar image Eckhard.Duken Feb 12 '15 at 03:01 PM

Glad to hear that you fixed your issue. For my understanding it was the missing UPROPERTY() so if that's true, please mark the answer as solution so others know how to fix similiar issues. Also having something named U...Struct might be misleading as U is the prefix for UObjects and F is the prefix for structs within the engine code base.

avatar image Wrekk Feb 12 '15 at 03:25 PM

Yeah, I marked it as solved. And the struct was because I originally had it as a struct, but decided I wanted a class instead. :)

avatar image MickD777 Feb 12 '15 at 02:15 PM

Make sure your TArray is also using the UPROPERTY() macro, in fact, pretty much every property should have this, otherwise there is a chance this will happen.

avatar image Wrekk Feb 12 '15 at 03:27 PM

I'll keep that in mind, thanks. :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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