Directx Managed memory allocation problem.

Posted on 2006-03-21
Last Modified: 2013-12-21
Hi I'm trying to use Managed DirectX to display some CAD objects in a numerical simulation program written in C#.
The program requires the calculation of big sparse matrices that need a lot of memory.
The matrix solver is working fine and I could solve without problem the large linear system.
The problem comes when I've tried to add the classes for Directx display. The program doesn't crush nor throw a exception but the linear system gives totally different results.
I suppose that the Directx classes are messing with the memory i use for the matrix solver.
Does anyone know of memory allocation problems connected with the Managed Directx classes and are they any means to fix these problems?
I use the latest Directx SDK release.
Question by:bogdanfun
    LVL 17

    Accepted Solution

    I've used DX for a decade, can't offhand recall any sort of memory overwrite issues -- and any that existed were likely because I was passing in bad ptrs to DX to start with.

    Have you tried switching your DXSDK into Debug mode?  That activates more things like parameter checking (and likely some memory verification).

    I mean, anything is possible, I'd just be surprised...  Are you sure you don't have uninitialized variables yourself, and that when you instantiate DX those uninitialized values change (stuff at different offsets...)?  I've seen that problem before a LOT.


    Author Comment

    Hi Davebytes

    I think I found the reason why I get different results.
    When I allocate the DirectX classes all the mathematical operation are apparently done in float precision even for double data. That's seriously affects the linear system solver.
    For now I don't know why is this happening.

    Author Comment

    I've found the solution in a previous question

    Davebytes thanks for your try and I will award you the credits anyway.

    LVL 17

    Expert Comment

    You know, it's been so long since I've had to touch that flag I forgot all about it!

    Yes, the D3D runtime switches the FPU into single-precision mode for performance.  Additionally, the FPU mode will get re-set every time you call into D3D (supposedly) if you flag FpuPreserve.  I wouldn't be surprised if some 3D engines might have actually set and restore the FPU state, around say physics computations, to control/reduce the overhead of D3D doing it constantly... But I could be wrong.

    Glad you got it working,


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
    Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now