none
Exception:This method or property is not available because there is a memory or disk problem for word interop. RRS feed

  • Question

  • I got the exception mentioned in title while using word interop to create word document with contents. while adding more than 500 page data, COM gives Exception like "This method or property is not available because there is a memory or disk problem for word interop", if i make visible as true, word application seems to be can't add further.I don't know what behavior is this, and i tried to save that document after completing single content addition, i did this until all contents parsing completed. EvenThough its showing the same error. if i tried to close or save changes same exception will thrown. I need to know full complexities of interop like which can use or which can't use if any. Give brief about interop access.
    Wednesday, November 25, 2015 10:42 AM

Answers

  • Hi Sethu,

    COM implements a deterministic model for freeing memory. In COM, each object has a reference counter that tracks how many clients use it. As clients refer to object, that counter is incremented; as clients stop referring to the object, the counter is decremented. When the counter reaches zero, the object is immediately removed from memory.

    Conversely, the .NET Framework uses a non-deterministic approach to freeing memory. In the .NET Framework, objects are removed from memory as part of a garbage collection process that checks for objects that are no longer in use and it’s only done when necessary (typically, when memory is constrained).

    When using interop assemblies, managed .NET-based code interacts with a Runtime Callable Wrapper (RCW) that manages the COM object for .NET-based application. When using a COM object from a .NET-based application, there are two objects involved: the RCW (can be small) and the COM object(s) (may be large). Garbage collection is only aware of the size of RCW, not the COM object. Therefore, while the .NET-based application might release the RCW, garbage collection may not reclaim the RCW even as memory runs out, As long as the RCW stays in memory, the COM object that it manages stays in memory also.

    Base on your reply, you are going to automate word document with a console application, there are two mechanisms that ensure that COM objects are released from memory: the AppDomain object and the ReleaseComObject method. Using an AppDomain provides the simplest solution to managing COM objects but has performance costs and can expose a security risk (unloading an AppDomain unloads all the resources).

    For more information, please refer to:

    # Handling Complex COM Objects with Interop Assemblies

    https://msdn.microsoft.com/en-us/library/office/aa159887(v=office.11).aspx

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 30, 2015 2:31 AM
    Moderator

All replies

  • When a Word document is edited, Word maintains numerous "scratch" and temporary files. There is a memory limit for these. If you're writing a lot of commands without saving and clearing the Undo list, you can hit this limit. It sounds like that's what's happening. See this discussion, for example:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/f3fa88fd-0988-4813-9959-7ed9a8b43ea8/word-insufficient-memory-exception

    If you're using a lot of direct formatting instead of creating and applying styles this will quickly hit the limitations...


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    Wednesday, November 25, 2015 4:03 PM
    Moderator
  • Hi Cindy,

    I couldn't work full fledged with word interop because i don't know fully about like where com exception will thrown if i use some critical like table with merged, split-ted and table properties. i need to know fully about word interop, if you can help me means send some interesting things which can i know about interop. i can automate word document with simple console application, and i can do simple things like creating, opening, writing some contents which doesn't affect much with word. and i need to know some recursive performance with application and range object of word interop. if you have understanding problem with what i post here, clarify with me and tell me what i need. importantly what i'm trying to ask, just help me so that i can understand about word interop not much like sky just like bird flying around that.

    Thanks,

    setHUMANikkam.y

    Friday, November 27, 2015 9:22 AM
  • Hi Sethu,

    COM implements a deterministic model for freeing memory. In COM, each object has a reference counter that tracks how many clients use it. As clients refer to object, that counter is incremented; as clients stop referring to the object, the counter is decremented. When the counter reaches zero, the object is immediately removed from memory.

    Conversely, the .NET Framework uses a non-deterministic approach to freeing memory. In the .NET Framework, objects are removed from memory as part of a garbage collection process that checks for objects that are no longer in use and it’s only done when necessary (typically, when memory is constrained).

    When using interop assemblies, managed .NET-based code interacts with a Runtime Callable Wrapper (RCW) that manages the COM object for .NET-based application. When using a COM object from a .NET-based application, there are two objects involved: the RCW (can be small) and the COM object(s) (may be large). Garbage collection is only aware of the size of RCW, not the COM object. Therefore, while the .NET-based application might release the RCW, garbage collection may not reclaim the RCW even as memory runs out, As long as the RCW stays in memory, the COM object that it manages stays in memory also.

    Base on your reply, you are going to automate word document with a console application, there are two mechanisms that ensure that COM objects are released from memory: the AppDomain object and the ReleaseComObject method. Using an AppDomain provides the simplest solution to managing COM objects but has performance costs and can expose a security risk (unloading an AppDomain unloads all the resources).

    For more information, please refer to:

    # Handling Complex COM Objects with Interop Assemblies

    https://msdn.microsoft.com/en-us/library/office/aa159887(v=office.11).aspx

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 30, 2015 2:31 AM
    Moderator
  • Thank you Starain chen,

    I'm very thankful for your suggestion which you gave here. i'll do the necessary action regards to improve my word automation of my console application. I'll post here if i faced any problem or if i need any suggestions.

    Thanks,

    Sethu.

    Monday, November 30, 2015 3:39 AM
  • Hi Sethu,

    Please feel free to post the issue here (related) or open new thread if you have issues/questions in future.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 30, 2015 5:35 AM
    Moderator