Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. memory allocation issues

memory allocation issues

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structuresperformancetutorialquestion
7 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tguzella
    wrote on last edited by
    #1

    hi there, i am writing a c++ program to make statistical analysis, which demands quite some memory (i'm using new to allocate an array and filling it with values)... whenever i need to allocate close to 200 mb the program and the computer gets really slow, taking forever just to allocate the memory... this happen when compilling on vc 6 and vc 7. when using dev c++ (mingw), the program just crashes while trying to allocate the memory... i am pretty much sure thats nothing to deal with memory leaks (all memory allocate is freed in the end), bad memory chips (i tested them using memtest) or insufficient memory (this pc runs with 2 gb of ram memory)... any suggestions on how to solve this??????

    D Z N J T 5 Replies Last reply
    0
    • T tguzella

      hi there, i am writing a c++ program to make statistical analysis, which demands quite some memory (i'm using new to allocate an array and filling it with values)... whenever i need to allocate close to 200 mb the program and the computer gets really slow, taking forever just to allocate the memory... this happen when compilling on vc 6 and vc 7. when using dev c++ (mingw), the program just crashes while trying to allocate the memory... i am pretty much sure thats nothing to deal with memory leaks (all memory allocate is freed in the end), bad memory chips (i tested them using memtest) or insufficient memory (this pc runs with 2 gb of ram memory)... any suggestions on how to solve this??????

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      tguzella wrote: whenever i need to allocate close to 200 mb the program and the computer gets really slow, taking forever just to allocate the memory This sounds reasonable. Allocating that much requires a good deal of work by the memory manager, including lots of virtual disk activity.


      Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

      1 Reply Last reply
      0
      • T tguzella

        hi there, i am writing a c++ program to make statistical analysis, which demands quite some memory (i'm using new to allocate an array and filling it with values)... whenever i need to allocate close to 200 mb the program and the computer gets really slow, taking forever just to allocate the memory... this happen when compilling on vc 6 and vc 7. when using dev c++ (mingw), the program just crashes while trying to allocate the memory... i am pretty much sure thats nothing to deal with memory leaks (all memory allocate is freed in the end), bad memory chips (i tested them using memtest) or insufficient memory (this pc runs with 2 gb of ram memory)... any suggestions on how to solve this??????

        Z Offline
        Z Offline
        ZoogieZork
        wrote on last edited by
        #3

        Is this memory being allocated in lots of tiny chunks or as one big array? In either case, the virtual memory manager will be working overtime to figure out how to arrange blocks and track them. If you have a whole bunch of tiny memory blocks, you might consider allocating a large pool of memory at the start of the day and writing your own allocator tuned to your requirements. - Mike

        1 Reply Last reply
        0
        • T tguzella

          hi there, i am writing a c++ program to make statistical analysis, which demands quite some memory (i'm using new to allocate an array and filling it with values)... whenever i need to allocate close to 200 mb the program and the computer gets really slow, taking forever just to allocate the memory... this happen when compilling on vc 6 and vc 7. when using dev c++ (mingw), the program just crashes while trying to allocate the memory... i am pretty much sure thats nothing to deal with memory leaks (all memory allocate is freed in the end), bad memory chips (i tested them using memtest) or insufficient memory (this pc runs with 2 gb of ram memory)... any suggestions on how to solve this??????

          N Offline
          N Offline
          Neville Franks
          wrote on last edited by
          #4

          Well allocating 200M sounds like a really bad idea, and is going to take quite some time. I'd be trying to find better algorithm or implementation of your algorithm that doesn't need such vast amounts of memory, or acquires it only as needed. There are also small memory block allocators around which will considerably improve performance if you are allocating lots of small blocks. Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com

          1 Reply Last reply
          0
          • T tguzella

            hi there, i am writing a c++ program to make statistical analysis, which demands quite some memory (i'm using new to allocate an array and filling it with values)... whenever i need to allocate close to 200 mb the program and the computer gets really slow, taking forever just to allocate the memory... this happen when compilling on vc 6 and vc 7. when using dev c++ (mingw), the program just crashes while trying to allocate the memory... i am pretty much sure thats nothing to deal with memory leaks (all memory allocate is freed in the end), bad memory chips (i tested them using memtest) or insufficient memory (this pc runs with 2 gb of ram memory)... any suggestions on how to solve this??????

            J Offline
            J Offline
            John M Drescher
            wrote on last edited by
            #5

            Well I would say for me 200MB is not a lot of memory. My program allocates almost 2GB which is the maximum allowed by the version of windows I am using. I do my allocations using VirtualAlloc(). I have almost 2GB of free memory and my allocations are instantaneous (take a few microseconds if you are counting). The first thing I would say is to check task manager to see if you have any free ram before you do the allocation. Are you using any third party memory products?? The ones that claim to give you more memory?? If so disable them and see what happens... John

            1 Reply Last reply
            0
            • T tguzella

              hi there, i am writing a c++ program to make statistical analysis, which demands quite some memory (i'm using new to allocate an array and filling it with values)... whenever i need to allocate close to 200 mb the program and the computer gets really slow, taking forever just to allocate the memory... this happen when compilling on vc 6 and vc 7. when using dev c++ (mingw), the program just crashes while trying to allocate the memory... i am pretty much sure thats nothing to deal with memory leaks (all memory allocate is freed in the end), bad memory chips (i tested them using memtest) or insufficient memory (this pc runs with 2 gb of ram memory)... any suggestions on how to solve this??????

              T Offline
              T Offline
              tguzella
              wrote on last edited by
              #6

              actually i am allocating this memory for 3 arrays... i am not using any third party allocation program... If this might be the problem, could anyone suggest me one to use (a freeware if possible :)...)??? i am running this on windows 2k (sp3) (i know i should be running on a real operating system: linux/unix, not this microsoft crap; i have no one to blame but myself for sticking with windows :(...), with 1.7 gb of free memory (that's why I am assuming problems are not coming from virtual memory...) thanx...

              Z 1 Reply Last reply
              0
              • T tguzella

                actually i am allocating this memory for 3 arrays... i am not using any third party allocation program... If this might be the problem, could anyone suggest me one to use (a freeware if possible :)...)??? i am running this on windows 2k (sp3) (i know i should be running on a real operating system: linux/unix, not this microsoft crap; i have no one to blame but myself for sticking with windows :(...), with 1.7 gb of free memory (that's why I am assuming problems are not coming from virtual memory...) thanx...

                Z Offline
                Z Offline
                ZoogieZork
                wrote on last edited by
                #7

                If it's only three arrays, is there any way you can allocate those three at the start of the program, then just re-use them? - Mike

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups