vb.net - Classes, references to save memory -
i have class follows:
public class courses public coursesofferedmain new list(of category) public courseslist new list(of course) public semslist new list(of sem) public subjectslist new list(of subjects) public examstypelist new list(of examtype) public class category private categoryname string private deleted boolean public courses new list(of course) end class public class course private categoryname string private courseid string private coursename string private deleted boolean public sems new list(of sem) end class public class sem private categoryname string private courseid string private semid string private semname string private deleted boolean public subjects new list(of subjects) end class public class subjects private categoryname string private courseid string private semid string private subjectid string private subjectname string private deleted boolean public exams new list(of examtype) end class public class examtype private categoryname string private courseid string private semid string private subjectid string private examtypeid string private examname string private exammax string private exammin string private exampass string private deleted boolean end class public sub updatelists() courseslist.clear() semslist.clear() subjectslist.clear() examstypelist.clear() each cat category in coursesofferedmain each cour course in cat.courses courseslist.add(cour) each sems sem in cour.sems semslist.add(sems) each subj subjects in sems.subjects subjectslist.add(subj) each exam examtype in subj.exams examstypelist.add(exam) next next next next next end sub end class
there no problem code how ever, know, in process following, number of subjects, couses, examsets etc repeated in specific type lists subjectslist, examstypelist etc.. since being copied on take more memory.
hence, question or doubt be, possible use same references instead of copying them on lists save memory, or there methods better this?
you using references. classes reference types, when copy objects copying references objects.
Comments
Post a Comment