Results 1 to 10 of 38

Thread: PGD - Some thoughts about the future

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Quote Originally Posted by User137 View Post
    Imagine that you have [0..0] pointer array of size 1024 and you increase the size by 1 for 10 times in a row. Dynamic array makes only 1 memory allocation of 2kb, but pointer array makes reservation total over 10kb (1025, 1026...1034)! In addition to that, it's like a puzzle game in the memory - having odd sized memory blocks of random 1023, 1050 etc are harder to organize than if the blocks are evenly sized.
    (Oh, what also happens on array resizing, is existing memory copied to new array. Again Setlength() would win by big margin.)
    As an aside on this note, I'd be very interested in any tests/information anyone has on this. I use a lot of dynamic arrays that seem to behave themselves. My assumption is that its written that way to avoid causing memory fragmentation for memory sizes that scale linearly across all orders of magnitude (ie. there are x allocations done to get from 1KiB to 1MiB and another x allocations to get from 1MiB to 1GiB). I agree it could be better done. The question is what does it understand by 'allocate'? Is it allocating virtual, private or some other 'kind' of memory so that it has the memory needed/mapped/allocated but the OS can use it for other things until the array grows to that size?
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  2. #2
    Quote Originally Posted by code_glitch View Post
    As an aside on this note, I'd be very interested in any tests/information anyone has on this.
    Iztok Kacin is trying to create better dynamical array by slicing it into smaller pieces. You can read some info on this on his blog here: http://www.cromis.net/blog/2013/03/i...-sliced-array/
    He also offers several comparion tests between his and regular dynamic arrays.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •