0
votes

I've been trying to get a piece of code working to reallocate a huge unmanaged matrix structure (namely std::vector<std::vector<T> >) to an equivalent managed structure( cli::array<T,2>). As I can't hold both structures in memory at once I opted to write to a file and read the structure back. The problem is that once I delete the original matrix, and hence the memory trying to allocate managed memory for the matrix fails.

I image this might have something to do with the heaps of different runtimes cpp vs clr. But can't find any specific details. Is it possible that the cpp runtime is keeping heap space, that prevents clr heap to allocate matrix back? If so, is it possible to force the cpp runtime to clean heap space in order to make room for the clr heap.

Now just to clarify, the destination matrix has to be a bidimensional array, not a jagged array. I know this has the problem that can't be resized. Otherwise I might be able to move the matrix by smaller chunks.

Thanks, in advance.

1
Not being able to use a jagged array is a pretty artificial restriction. It certainly does solve your address space fragmentation problem. A 64-bit operating system is the simple workaround.Hans Passant

1 Answers

0
votes

If you can't have both in memory at the same time, I guess the array is more than a gigabyte in size. If you want to put that in a managed rectangular (non-jagged) array, the CLR will have to find a gigabyte of contiguous memory... That could fail easily.

Have you tried to run a 64 bit version, or a 32 bit version declared as "large adress awarene"? The latter will give you 4 gigabytes adress space if running on a 64 bit windows machine, it just might fit.