# Compilation error:../Common/Core/vtkOStreamWrapper.h:108: memory exhausted

**URL:** https://discourse.vtk.org/t/compilation-error-common-core-vtkostreamwrapper-h-memory-exhausted/9280
**Category:** Support
**Created:** [September 5, 2022, 9:46am UTC](https://discourse.vtk.org/t/compilation-error-common-core-vtkostreamwrapper-h-memory-exhausted/9280 "2022-09-05T09:46:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![AlexLuya](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alexluya/32/4036_2.png) [@AlexLuya](https://discourse.vtk.org/u/AlexLuya)
#### Post date: [September 5, 2022, 9:46am UTC](https://discourse.vtk.org/t/compilation-error-common-core-vtkostreamwrapper-h-memory-exhausted/9280/1 "2022-09-05T09:46:29Z")

</div>

I got a compilation error:

```auto
 vtkWrapHierarchy-9.1: In /home/user/workspace/VTK/Common/Core/vtkOStreamWrapper.h:108: memory exhausted.
make[2]: *** [Common/Core/CMakeFiles/vtkCommonCore-hierarchy.dir/build.make:281: lib/x86_64-linux-gnu/vtk/hierarchy/VTK/vtkCommonCore-hierarchy.txt] Error 1
make[1]: *** [CMakeFiles/Makefile2:4211: Common/Core/CMakeFiles/vtkCommonCore-hierarchy.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

```

The line 108 of vtkOStreamWrapper is like this:

```auto
  // Accept std::string without a declaration.
    template <template <typename, typename, typename> class S> ---------------- line 108
    vtkOStreamWrapper& operator<<(const S<char, std::char_traits<char>, std::allocator<char>>& s)
    {
      return *this << reinterpret_cast<std_string const&>(s);
    }

```

**1, Any suggestiont to fix this problem?**

After some digging,I found

`Common/Core/CMakeFiles/vtkCommonCore-hierarchy.dir/build.make:281`

is this:

```auto
cd /home/alex/workspace/VTK/Debug/Common/Core && ../../bin/vtkWrapHierarchy-9.1 @/home/alex/workspace/vtk/Debug/Common/Core/CMakeFiles/vtkCommonCore-hierarchy.Debug.args -o /home/alex/workspace/vtk/Debug/lib/x86_64-linux-gnu/vtk/hierarchy/vtk/vtkCommonCore-hierarchy.txt /home/alex/workspace/vtk/Debug/Common/Core/CMakeFiles/vtkCommonCore-hierarchy.data @/home/alex/workspace/vtk/Debug/Common/Core/CMakeFiles/vtkCommonCore-hierarchy.depends.args

```

After running this line,same error got printed out as above.

**2,Does this only print already generated compilation error?Or above error is actually generated by this line?**

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [September 5, 2022, 10:56am UTC](https://discourse.vtk.org/t/compilation-error-common-core-vtkostreamwrapper-h-memory-exhausted/9280/2 "2022-09-05T10:56:13Z")

</div>

> [@AlexLuya](#):
>
> `tkOStreamWrapper.h:108: memory exhausted.`

You are out of memory

---

<div class="post-metadata">

### Author: ![AlexLuya](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alexluya/32/4036_2.png) [@AlexLuya](https://discourse.vtk.org/u/AlexLuya)
#### Post date: [September 5, 2022, 1:47pm UTC](https://discourse.vtk.org/t/compilation-error-common-core-vtkostreamwrapper-h-memory-exhausted/9280/3 "2022-09-05T13:47:14Z")

</div>

Thanks,but systemo monitor says ‘NO’,10 GB memory left during compilation,no usage peaks.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [September 5, 2022, 1:48pm UTC](https://discourse.vtk.org/t/compilation-error-common-core-vtkostreamwrapper-h-memory-exhausted/9280/4 "2022-09-05T13:48:40Z")

</div>

Does it fails again on the same location if you rerun ?

---

<div class="post-metadata">

### Author: ![AlexLuya](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alexluya/32/4036_2.png) [@AlexLuya](https://discourse.vtk.org/u/AlexLuya)
#### Post date: [September 5, 2022, 1:54pm UTC](https://discourse.vtk.org/t/compilation-error-common-core-vtkostreamwrapper-h-memory-exhausted/9280/5 "2022-09-05T13:54:10Z")

</div>

Yes

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [September 5, 2022, 1:56pm UTC](https://discourse.vtk.org/t/compilation-error-common-core-vtkostreamwrapper-h-memory-exhausted/9280/6 "2022-09-05T13:56:31Z")

</div>

Looks like a @ben.boeckel question then

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [September 7, 2022, 7:17pm UTC](https://discourse.vtk.org/t/compilation-error-common-core-vtkostreamwrapper-h-memory-exhausted/9280/7 "2022-09-07T19:17:47Z")

</div>

It seems like there’s a rogue pointer around and it finally found a `NUL` way off into the weeds. Could you run the failing it under `valgrind` to see if it detects anything?

Cc: @dgobbi

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [September 8, 2022, 1:08pm UTC](https://discourse.vtk.org/t/compilation-error-common-core-vtkostreamwrapper-h-memory-exhausted/9280/8 "2022-09-08T13:08:55Z")

</div>

I’ve never seen this error before or heard any reports about it. But you can probably work around it by using an `#if` to tell vtkWrapHierarchy to ignore that part of the header file,

```diff
+#if !defined( __VTK_WRAP__ )
   // Accept std::string without a declaration.
   template <template <typename, typename, typename> class S>
   vtkOStreamWrapper& operator<<(const S<char, std::char_traits<char>, std::allocator<char>>& s)
   {
     return *this << reinterpret_cast<std_string const&>(s);
   }
+#endif

```

The vtkWrapHierarchy program has an embedded C++ parser, and for some reason it is failing to parse this `operator<<` template on your system. Which is strange, because it succeeds without any errors on my system and everyone else’s. My best guess is this: for your build of VTK, an extra header file is being included somewhere that `#define`s a macro for `std_string` or `S` or for one of the other identifiers that is used in the `operator<<` definition.

Edit: I ran the vtkWrapHierarchy command line under valgrind and it didn’t detect any issues.

```nohighlight
valgrind --tool=memcheck bin/vtkWrapHierarchy-9.2 @Common/Core/CMakeFiles/vtkCommonCore-hierarchy.RelWithDebInfo.args -o /tmp/vtk-9.2/hierarchy/VTK/vtkCommonCore-hierarchy.txt Common/Core/CMakeFiles/vtkCommonCore-hierarchy.data @Common/Core/CMakeFiles/vtkCommonCore-hierarchy.depends.args

```

Admittedly, this was for VTK 9.2 rather than 9.1.
