我正在开发限制内存的C#应用程序。我初始化了大量的对象,如下面那些有几个属性的对象,大约需要20MB。如何减少我的应用程序使用的内存量。减少我的应用程序的内存占用量
public class BusStop
{
private List<BusRoute> busRoutes = new List<BusRoute>();
private string name;
// ... Other properties omitted like Code, ID, Location, etc.
public BusStop(string name)
{
this.name = name;
}
public List<BusStop> BusRoutes
{
get { return this.busRoutes; }
}
public string Name
{
get { return this.name; }
}
}
public class BusRoute
{
private List<BusStop> busStops = new List<BusStop>();
private string name;
// ... Other properties omitted like Code, ID, Location, etc.
public BusStop(string name)
{
this.name = name;
}
public List<BusStop> BusStops
{
get { return this.busStops; }
}
public string Name
{
get { return this.name; }
}
}
我不禁注意到你存储BusRoute的每一站和巴士站就为每一个路线,不是吗”那是浪费内存?因为每个节点都是BusStop,所以你的情况不会更有效。 – alykhalid 2012-03-08 09:32:47