Elvas Tower: memory using monogame or - Elvas Tower

Jump to content

  • 8 Pages +
  • « First
  • 3
  • 4
  • 5
  • 6
  • 7
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

memory using monogame or Rate Topic: -----

#41 User is offline   Haran Banjo 

  • Hostler
  • Group: Status: Active Member
  • Posts: 55
  • Joined: 12-November 19
  • Gender:Male
  • Simulator:Open Rails
  • Country:

Posted 16 December 2021 - 10:47 AM

 Csantucci, on 12 December 2021 - 12:45 AM, said:

Yes, it works now. Good job!



I also have the same problem with the signals, how is it solved?

#42 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 7,016
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 17 December 2021 - 01:23 AM

I'm merging into ORNYMG Cédric's improvements with the ones that were already present there (subject to the selection of the Reduce Memory Usage option).
Doing this I noticed that I had also modified Sweep() this way within Shapes.cs
        public void Sweep()
        {
            foreach (var path in ShapeMarks.Where(kvp => !kvp.Value).Select(kvp => kvp.Key))
            {
                var shape = Shapes[path];
                Shapes.Remove(path);
                if (Viewer.Settings.ReduceMemory)
                {
                    foreach (var lod in shape.LodControls)
                        for (var subObjectIndex = 0; subObjectIndex < lod.DistanceLevels[0].SubObjects.Length; subObjectIndex++)
                            foreach (var prim in lod.DistanceLevels[0].SubObjects[subObjectIndex].ShapePrimitives)
                                prim.VertexBuffer.Dispose();
                    shape = null;
                }
            }
        }

I wonder whether this can be of interest.

#43 User is offline   gpz 

  • Superintendant
  • Group: Status: Elite Member
  • Posts: 1,772
  • Joined: 27-October 12
  • Gender:Male
  • Location:Budapest
  • Simulator:OpenRails
  • Country:

Posted 17 December 2021 - 01:48 AM

As I glanced into the code, these all should actually be IDisposables (the Shape, LodControl, DistanceLevel, Subobject, ShapePrimitive), because the lowest level ShapePrimitive has two disposable members: the VertexBuffer and the Indexbuffer. (Carlo, you might have also needed to dispose the latter: prim.IndexBuffer.Dispose(); )

And the call would be simply
var shape = Shapes[path];
Shapes.Remove(path);
shape.Dispose();

, and it would roll down by the chain.

#44 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 7,016
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 17 December 2021 - 03:44 AM

Thanks Peter,
C# does not like shape.Dispose(), because it doesn't find the method. Instead I could add prim.IndexBuffer.Dispose();.

#45 User is offline   gpz 

  • Superintendant
  • Group: Status: Elite Member
  • Posts: 1,772
  • Joined: 27-October 12
  • Gender:Male
  • Location:Budapest
  • Simulator:OpenRails
  • Country:

Posted 17 December 2021 - 05:54 AM

I mentioned the shape.Dispose(), because that would be the "clean" implementation. All of the classes in the chain must implement the IDisposable interface, and all of them implement the Dispose() method, which calls all the member's own Dispose(). The basic thumb-rule is that every class has to implement the IDisposable interface that has at least one IDisposable member.

#46 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 7,016
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 17 December 2021 - 07:20 AM

OK, I see.
I have now performed the merge as described here http://www.elvastowe...post__p__279251 , and this is available in ORNYMG rev. 112. In ORNYMG the feature requires the general option Reduce Memory Usage to be checked; the requirement will probably be removed when the feature will become tested enough.

#47 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 7,016
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 17 December 2021 - 08:48 AM

A user reports a crash in the Loading screen dispose, because his test route has no loading screen...

#48 User is offline   Serana 

  • Conductor
  • Group: Status: Contributing Member
  • Posts: 489
  • Joined: 21-February 13
  • Gender:Male
  • Location:St Cyr l'Ecole (France)
  • Simulator:Open Rails
  • Country:

Posted 17 December 2021 - 06:14 PM

Ok, I will add a null-conditional operator to this.

#49 User is offline   akioyamamura 

  • Hostler
  • Group: Status: Active Member
  • Posts: 75
  • Joined: 30-August 21
  • Gender:Male
  • Simulator:Open Rails
  • Country:

Posted 22 December 2021 - 05:32 AM

I'm trying the "reduce memory usage" feature, and having a minor problem with the ACCELEROMETER. As you can see in the video the accelerometer it's working fine until 3:37 and than he disappear, when it's need to show the positive value. It's happens in every path that I tried and sometimes the negative value disappear too. Deactivating the "reduce memory usage" everything works again. Just to clarified the accelerometer number are highlighted in the printscreen attched.
Tested with 32 bits box checked too, but the problem persists.
Thank you.

https://youtu.be/VlRMdvr8hus

Attached File(s)



#50 User is offline   Serana 

  • Conductor
  • Group: Status: Contributing Member
  • Posts: 489
  • Joined: 21-February 13
  • Gender:Male
  • Location:St Cyr l'Ecole (France)
  • Simulator:Open Rails
  • Country:

Posted 22 December 2021 - 08:50 AM

 Csantucci, on 17 December 2021 - 01:23 AM, said:

I'm merging into ORNYMG Cédric's improvements with the ones that were already present there (subject to the selection of the Reduce Memory Usage option).
Doing this I noticed that I had also modified Sweep() this way within Shapes.cs
        public void Sweep()
        {
            foreach (var path in ShapeMarks.Where(kvp => !kvp.Value).Select(kvp => kvp.Key))
            {
                var shape = Shapes[path];
                Shapes.Remove(path);
                if (Viewer.Settings.ReduceMemory)
                {
                    foreach (var lod in shape.LodControls)
                        for (var subObjectIndex = 0; subObjectIndex < lod.DistanceLevels[0].SubObjects.Length; subObjectIndex++)
                            foreach (var prim in lod.DistanceLevels[0].SubObjects[subObjectIndex].ShapePrimitives)
                                prim.VertexBuffer.Dispose();
                    shape = null;
                }
            }
        }

I wonder whether this can be of interest.


This is indeed interesting, I will introduce something similar, but with the refactoring proposed by Peter.

  • 8 Pages +
  • « First
  • 3
  • 4
  • 5
  • 6
  • 7
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users