Is it possible in the object constructor to somehow interrogate whether there is enough memory to create it? Now I catch through Exception, but I would like to foresee it a bit earlier ... and generally display the current memory used by the application ...

  • one
    At the time of the constructor call, the memory is already allocated. You can override the NewInstance, and whether it has enough memory - Vasek
  • @Vasek, acceptable ... but how to calculate it? - Isaev
  • If there is such a question - something obviously goes wrong. What kind of objects are these? - MBo
  • one
    You can create your own memory manager, which records each allocation and release, and then calls the standard memory manager. But besides the exhaustion of the amount of memory there is a problem with fragmentation. In total, there may be a lot of memory, but it will not work out to select a piece of the required length. - German Borisov
  • 2
    The memory occupied by the application can be queried via GetProcessMemoryInfo. And free, for example, through GlobalMemoryStatusEx. But @ HermanBorisov is right, with the clarification of information about fragmentation it will not be all easy - Viktor Tomilov

0