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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. a problem in memory allocation

a problem in memory allocation

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebuggingperformancequestion
3 Posts 2 Posters 0 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.
  • G Offline
    G Offline
    Gerald Mercet
    wrote on last edited by
    #1

    Hi everybody, I have a strange problem with an allocation of memory for pointers of pointers. i have done this function to allocate memory for 2 pointers of pointers: void LoadHistoDB::AllocComptStartEndMin(long RowSize,long ColSize) { long i; pComptStartMineure=new double* [RowSize]; pComptEndMineure=new double* [RowSize]; for(i=0;i120 i could see in the debug window this message in front of pComptStartMineure: CXX0030:expression cannot be evaluated and i could see this same message for pComptEndMineure when i>202. So where is the problem? Thanks in advance for your help gérald

    T 1 Reply Last reply
    0
    • G Gerald Mercet

      Hi everybody, I have a strange problem with an allocation of memory for pointers of pointers. i have done this function to allocate memory for 2 pointers of pointers: void LoadHistoDB::AllocComptStartEndMin(long RowSize,long ColSize) { long i; pComptStartMineure=new double* [RowSize]; pComptEndMineure=new double* [RowSize]; for(i=0;i120 i could see in the debug window this message in front of pComptStartMineure: CXX0030:expression cannot be evaluated and i could see this same message for pComptEndMineure when i>202. So where is the problem? Thanks in advance for your help gérald

      T Offline
      T Offline
      tongc
      wrote on last edited by
      #2

      When i>120 i could see in the debug window this message in front of pComptStartMineure: CXX0030:expression cannot be evaluated `that means that your pointer is pointing to NULL, hence it can not evaluated the value. Normally, an attempt to access NULL pointer will give you "Access Violation" error. This dynamic memory allocation is not easy to deal with. Ideally you'll need to go step by step through each line of code and monitor your program and see what is an unexpected result.`

      G 1 Reply Last reply
      0
      • T tongc

        When i>120 i could see in the debug window this message in front of pComptStartMineure: CXX0030:expression cannot be evaluated `that means that your pointer is pointing to NULL, hence it can not evaluated the value. Normally, an attempt to access NULL pointer will give you "Access Violation" error. This dynamic memory allocation is not easy to deal with. Ideally you'll need to go step by step through each line of code and monitor your program and see what is an unexpected result.`

        G Offline
        G Offline
        Gerald Mercet
        wrote on last edited by
        #3

        I try to follow first the allocation describe by the function called AllocComptStartEndMin, and you know as usual when you do the allocation of memory for a pointer of "double" for example, p=new double[X]; when you try to see what are the value, for each i from 0 to to X-1 of p[i], (before any affectation), in the debug window, you have in this window: p[i] in the column "Name" and -6.2774385...e+066 in "Value" column. So when i execute step by step AllocComptStartEndMin, it works even if i>120. So, why when i want to affect value to the pointers i can't affect value for the first pointer when i>120 ( and what is very strange is this value:120, because in my sample RowSize =866 and ColSize=255!)

        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