Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with boolean
#4
Memnew just grabs a free spot in memory and reserves it for your use.  Now if that memory has always been unused, it's probably all 0s.  But if it's using a portion of memory that had been used previously and then freed, then it's going to have that old data in it.

Most of the time (like when creating an array), data goes through two steps: Reserve it and Initialize it.

Since Mem is optimized for speed, it skips that second step.

Instead of:  Reserve it.  Initialize it to 0.  Put data in it.
It is simply: Reserve it.  Put data in it.

I'm certain you can see where the second has to be faster than the first when running it.  The only problem comes if you read it before you fill it up with your own data.  You end up getting junk in it, as you've seen for yourself in your own stuff above.
Reply


Messages In This Thread
Need help with boolean - by Petr - 11-13-2024, 08:53 PM
RE: Need help with boolean - by SMcNeill - 11-13-2024, 10:08 PM
RE: Need help with boolean - by Petr - 11-13-2024, 10:22 PM
RE: Need help with boolean - by SMcNeill - 11-13-2024, 10:32 PM
RE: Need help with boolean - by bplus - Yesterday, 03:28 PM
RE: Need help with boolean - by Pete - Yesterday, 05:30 PM



Users browsing this thread: 3 Guest(s)