mkazhdan / PoissonRecon

Poisson Surface Reconstruction
MIT License
1.51k stars 422 forks source link

The problem about the MFC interface #22

Open hushanming opened 7 years ago

hushanming commented 7 years ago

Hi,@mkazhdan First,thank you for providing the PoissonRecon project. I recently used your code and made some changes to it.I used the MFC interface to run the code,rather than the console cause I found it will take part of the memory when the end of the operation.So I have some problems.When I first choose the point-set file ,run the code and it run perfectly,however when I choose the file(the same as the first or not)and run the code,it collapsed(I did not withdraw MFC in this process). I try to debug this code,but I could not find th reason.My compiler is visual studio 2013.Thank you.

mkazhdan commented 7 years ago

I'm afraid I don't know much about MCF. However, one of the problems that people have had is that the compiler is set to use the latest SSE instruction set. If your hardware doesn't support it, the executable will crash. You can fix this by setting the instruction set to SSE2.

-- misha

On December 20, 2016 4:19:04 AM EST, hushanming notifications@github.com wrote:

Hi,@mkazhdan First,thank you for providing the PoissonRecon project. I recently used your code and made some changes to it.I used the MFC interface to run the code,rather than the console cause I found it will take part of the memory when the end of the operation.So I have some problems.When I first choose the point-set file ,run the code and it run perfectly,however when I choose the file(the same as the first or not)and run the code,it collapsed(I did not withdraw MFC in this process). I try to debug this code,but I could not find th reason.My compiler is visual studio 2013.Thank you.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/mkazhdan/PoissonRecon/issues/22

hushanming commented 7 years ago

Hi,@mkazhdan Thank you for your reply,I found the reason is in the code,the SetAllocator is a static function.So the memory would clear after the process finished.But if I want the code continuous operation twice,it would collapsed in the code,because the memory is not released,so the _spaceRoot value would changed after call function.The problem is that I could not change the code in your project? Could you please give me some addvices about this ? Thank you.

hushanming commented 7 years ago

Hi,@mkazhdan I'm sorry to bother you,I found there is a memory leak at the code.It has not been released before the end of the progam and it continue to increase when calling this code. Thank you.

markloyman commented 6 years ago

Hi @hushanming , Did you manage to find a solution for this problem?

markloyman commented 6 years ago

If you run Poisson for a second time (note: this has nothing to do with MFC):

Calling OctNode< NodeData >::SetAllocator(MEMORY_ALLOCATOR_BLOCK_SIZE) breaks the data in Octree< Real > tree; (which is initialized few lines of code before).

This can be resolved by setting MEMORY_ALLOCATOR_BLOCK_SIZE to 0 (in which case, we are not using the Allocator class).

What consequences are there to not using the Allocator class?

UPDATE: It seems that the issue can also be resolved while continuing to use the Allocator class, by changing the set() method in Allocator.h to:

    void set( int blockSize )
    {
        if (this->blockSize != blockSize)
        {
            reset();
            this->blockSize = blockSize;
            index = -1;
            remains = 0;
        }
    }
mkazhdan commented 6 years ago

Sorry about that.

Calling with a MEMORY_ALLOCATOR_BLOCK_SIZE of 0 should work, but could make the tree construction slower (because octree nodes will be allocated one by one instead of in large groups).

I believe the problem can be fixed by moving the line:

            OctNode< TreeNodeData >::SetAllocator( MEMORY_ALLOCATOR_BLOCK_SIZE );

before the line declaring the tree:

            Octree< Real > tree;

This is because the Octree constructor uses the allocator. So if it is reset after, things could get wonky. (Still need to figure out why this doesn’t break on the first pass.)

-- Misha

From: Mark Loyman [mailto:notifications@github.com] Sent: Tuesday, October 10, 2017 4:30 AM To: mkazhdan/PoissonRecon PoissonRecon@noreply.github.com Cc: mkazhdan misha@cs.jhu.edu; Mention mention@noreply.github.com Subject: Re: [mkazhdan/PoissonRecon] The problem about the MFC interface (#22)

If you run Poisson for a second time (note: this has nothing to do with MFC):

Calling OctNode< NodeData >::SetAllocator(MEMORY_ALLOCATOR_BLOCK_SIZE) breaks the data in Octree< Real > tree; (which is initialized few lines of code before).

This can be resolved by setting MEMORY_ALLOCATOR_BLOCK_SIZE to 0 (in which case, we are not using the Allocator class).

What consequences are there to not using the Allocator class?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mkazhdan/PoissonRecon/issues/22#issuecomment-335400218 , or mute the thread https://github.com/notifications/unsubscribe-auth/AKXc5XmxMkS4rjRPJJI56KPmRtG5xLIQks5sqysegaJpZM4LRnkm . https://github.com/notifications/beacon/AKXc5VyQ9NgaUO6m4AbczrxI_jPlL8jaks5sqysegaJpZM4LRnkm.gif