News: Contact us to upgrade your software!

Author Topic: Memory Error when creating many groups with COM-Interface  (Read 18940 times)

Sebastian

  • Client
  • **
  • Posts: 6
    •  
Memory Error when creating many groups with COM-Interface
« on: August 19, 2013, 06:52:55 AM »
Hello,

I created a model with about 3500 components(beams and shells). Since I use the com-interface, each component gets it's own group. Importing the model with those components works perfectly fine. But when I try to create the respective groups, the first 1122 groups can be created and after that I receive an error. This error is probably a memory error. The component can be added and removed to/from the group using "ComponentMembership". However "group.Components.Count()" and "group.Components.Key(<keyname>)" does not return a component as can be seen in the following code. The last line (Error #3035) says "not enough Memory" in German. What can I do? (An image of the model is attached)

Code: [Select]
g=self.hsProject.Groups.Key(10000)
g
<win32com.gen_py.HyperSizer Advanced Structural Analysis Library, v6.4._Group instance at 0x364587928>
g.ComponentMembership([756075],[0])
True
g.GroupMembershipComponentList()
(756075,)
g.Components.Key(756075)
Traceback (most recent call last):
  File "C:\Eclipse\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydevd_comm.py", line 765, in doIt
    result = pydevd_vars.evaluateExpression(self.thread_id, self.frame_id, self.expression, self.doExec)
  File "C:\Eclipse\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydevd_vars.py", line 376, in evaluateExpression
    result = eval(compiled, updated_globals, frame.f_locals)
  File "<string>", line 1, in <module>
  File "C:\Python27\lib\site-packages\win32com\gen_py\36A23079-251A-43B3-8FE8-DB5E1FDAF0A6x0x7x0.py", line 1811, in Key
    ret = self._oleobj_.InvokeTypes(1745027083, LCID, 2, (9, 0), ((8, 1),),ComponentKey
com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, u'ComponentCol', u'Project Component Not Found', None, 1000440, -2147188693), None)

g.Components.Count()
0
g.ComponentMembership([0],[756075])
True
g.GroupMembershipComponentList()
()
g.ComponentMembership([756075],[0])
True
g.GroupMembershipComponentList()
(756075,)
g.Components.Count()
Traceback (most recent call last):
  File "C:\Eclipse\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydevd_comm.py", line 765, in doIt
    result = pydevd_vars.evaluateExpression(self.thread_id, self.frame_id, self.expression, self.doExec)
  File "C:\Eclipse\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydevd_vars.py", line 376, in evaluateExpression
    result = eval(compiled, updated_globals, frame.f_locals)
  File "<string>", line 1, in <module>
  File "C:\Python27\lib\site-packages\win32com\gen_py\36A23079-251A-43B3-8FE8-DB5E1FDAF0A6x0x7x0.py", line 1777, in Count
    return self._oleobj_.InvokeTypes(1610809367, LCID, 1, (3, 0), (),)
com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, u'Components [Property Get]', u'Unhandled Error, Application Error in ComponentCol::Components [Property Get]()\r\n\r\nLine #7, Error #-2147188733, Unhandled Error, Application Error in clsComponent::Init [Sub]()\r\n\r\nLine #7, Error #3035, Nicht gen\xfcgend Arbeitsspeicher.', None, 1000440, -2147188733), None)

cfriedland5

  • Client
  • **
  • Posts: 18
    •  
Re: Memory Error when creating many groups with COM-Interface
« Reply #1 on: August 19, 2013, 08:56:46 AM »
There's a few places in my model where Hypersizer mysteriously stops working in the middle of doing a repetitive task for the umpteenth time, probably due to memory, and in those places my fix is to include lines to close hypersizer and reopen it.

Ryan

  • Administrator
  • *****
  • Posts: 145
    •  
Re: Memory Error when creating many groups with COM-Interface
« Reply #2 on: August 19, 2013, 03:04:14 PM »
Yes. It is a memory issue. Like cfriedland5 says, the workaround is to make a counter and reload HyperSizer every couple hundred groups. The spreadsheet utilities Excel code uses this same workaround (Reload Project()).

Here's what it would look like in Python. Note that if you have an application that loops through the groups, you need to loop using the integer index (instead of using a 'for each' style loop).

    group_count = 0
    for g in range(project.Groups.Count()):

        group = project.Groups.Item(g+1)
        print (group.GroupName)

        # Reload HyperSizer (if necessary)
        group_count = group_count + 1
        if group_count == GROUP_COUNT_MAX: # Set this constant to around 400.
            hs = None
            project = None
            group_count = 0
            hs, project = reload_hypersizer(database_path, project_name)


-Ryan


Sebastian

  • Client
  • **
  • Posts: 6
    •  
Re: Memory Error when creating many groups with COM-Interface
« Reply #3 on: August 23, 2013, 07:15:56 AM »
Thanks, cfriedland5 and Ryan,

I tested it with this workaround. It works perfectly fine!

-Sebastain