Hi, I want to get every view's elements, so I will invoke API FilteredElementCollector(document, viewId) to get, but that are some problems with the API. I wrote a function to test, like bellow:
private void test(){
FilteredElementCollector viewCollector =
new FilteredElementCollector(m_document).OfCategory(BuiltInCategory.OST_Views);
foreach (Element viewElem in viewCollector)
{
Autodesk.Revit.DB.View curView = viewElem as Autodesk.Revit.DB.View;
if(!FilteredElementCollector.IsViewValidForElementIteration(m_document, curView.Id)) continue;
FilteredElementCollector viewElems =
new FilteredElementCollector(m_document,curView.Id).WhereElementIsNotElementType();
}
}
afte running test() will increate about 800MB of revit process (test model has 217 views and every view has the average of about 8000 elements) and lead to process crashed. Whether it is normal situation to consume so much memory or memory leak.
But If I change the last statement that remove the second param 'curView.Id' to tun again test(), it consumes very little memory. It means if invoke 'FilteredElementCollector(m_document,curView.Id)' will consumes memory, but invoke 'FilteredElementCollector(m_document)' will almost none.
Hello
Can you please let us know the Revit version, you see the reported behavior in? Will it be possible to proivde a Revit model that does not contain confidential information, that we can test using the code snippet you have provided below.
Once we can reproduce the reported crash behavior ay our end, we can ask the Development team to investigate further.
Thanks
My revit version is Revit Architecture 2012 Build:20110916_2132 Update Release 2.
so sorry, the model contains confidential information. I think that you can test by any model no need too big, and you can see from 'window Task Manager' the memory increase obviously.
Thanks
Hi
I did a check again with the RAC BASIC SAMPLE PROJECT rvt file and there was barely any increase in the memory usage.
If would greatly help if you can pass on a non-confidential Revt file using which we can reproduce the reported behvior. I can then pass the RVT and VS project with the code you have provided for the Development team to investigate further - after I have been able to reproduce it at my end.
thanks
Hi, In the I used the rac_advanced_sample_project(the model in the sample folder of revit install path) to run the test() function(the test function has written above) again, running in the view of "3D Views" -> "{3D}", if keep the filter like:
FilteredElementCollector viewElems =
new FilteredElementCollector(m_document, curView.Id).WhereElementIsNotElementType();
after runing test() will increate about 50MB meomery of revit process. If more biger model will comsume more meomery.
But if change to:
FilteredElementCollector viewElems =
new FilteredElementCollector(m_document).WhereElementIsNotElementType();
Notice: this statement get element by document not like above by view.
After changing and running the test() function, but this time increated almost no meomery.
I don't know whether this is bug, but get elements by document or by view will get the same elements (in 3d view), but why get elements by view will increase so much memory.
thank you.
Hi
Thanks for the update. I followed the exact same steps and
1) with the code which did use the Current view Id, the memory usage increased to 353356K from 346680K - which is about 6600 K or 6.4MB.
2) with the code which did not use the Current View Id, the memory usage increased to 380168 K from 378964 K - which is about 1204 K.
All this was tested with 3D view as the current active view and with build # 20120221_2030 (x64).
As you can see, the results are not comparable between what I see and what seems to be happening at your end (50 MB mem usage increase). If you have any other system handy, can you test this to see if this is specific to your system. Or, is there a difference between the builds or OS at your end and mine?
Thanks
Saikat
Hi,
My OS is Win7(X86) and revit version is Build: 20110916_2132 Update Release2. I am not sure if is the different OS or revit version.
But by your datas the filter use current view Id also consume about 5 times than no use view Id, but they are get the same elements, why use current view Id will consume so more memory.
By the way, actually I want to show elements by different views, so I need the 'new FilteredElementCollector(m_document, curView.Id)' to get every view's elements to show. If I can firstly get all elements of document(this time will consume less memory). then classify the elements to every view. Whether exist any API to classify them. Like 'OwnerViewId', but this obviously is null if there are geometry elements.
thanks