Class sharing between multiple virtual machines
First Claim
1. A method of operating a system including first and second virtual machines and having a shared memory accessible to both said first and second virtual machines, the method comprising the steps of:
- loading a class within the first virtual machine into said shared memory, said class having sharable and non-sharable data associated therewith;
loading the class into the second virtual machine by locating the class within said shared memory;
forming a mirror of the class within a private memory in the second virtual machine; and
utilising the class in the second virtual machine on the basis of the sharable data from the shared memory of the first virtual machine, and the non-sharable data from the private memory of the second virtual machine;
wherein said step of loading the class into the second virtual machine includes updating a class loader cache in the second virtual machine; and
wherein said first and second virtual machines both include a hierarchy of class loaders, at least one of which is a shared class loader, wherein each shared class loader in the class loader hierarchy in second virtual machine has a corresponding shared class loader in the equivalent position in the class loader hierarchy in the first virtual machine.
1 Assignment
0 Petitions
Accused Products
Abstract
A system includes first and second virtual machines (VM) representing a master and a client respectively. A class file is loading by the first virtual machine into shared memory. The class file includes sharable and non-sharable data, and also references sharable and non-sharable data (including code). When it is desired to load the same class into the second virtual machine, the class is first located within said shared memory. A mirror copy of the class is then formed within private memory in the second virtual machine. Finally the non-sharable data of the class is completed in the private memory. Thereafter, an application in the second virtual machine can utilise the class on the basis of the sharable data in the shared memory of the first virtual machine, and the non-sharable data from the private memory of the second virtual machine.
-
Citations
31 Claims
-
1. A method of operating a system including first and second virtual machines and having a shared memory accessible to both said first and second virtual machines, the method comprising the steps of:
-
loading a class within the first virtual machine into said shared memory, said class having sharable and non-sharable data associated therewith;
loading the class into the second virtual machine by locating the class within said shared memory;
forming a mirror of the class within a private memory in the second virtual machine; and
utilising the class in the second virtual machine on the basis of the sharable data from the shared memory of the first virtual machine, and the non-sharable data from the private memory of the second virtual machine;
wherein said step of loading the class into the second virtual machine includes updating a class loader cache in the second virtual machine; and
wherein said first and second virtual machines both include a hierarchy of class loaders, at least one of which is a shared class loader, wherein each shared class loader in the class loader hierarchy in second virtual machine has a corresponding shared class loader in the equivalent position in the class loader hierarchy in the first virtual machine. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10)
checking that an instance of the shared class loader does not already exist; and
checking that there is a corresponding shared class loader in the first virtual machine.
-
-
3. The method of claim 1, wherein the step of loading the class into the second virtual machine by locating the class within said shared memory comprises the steps of:
-
walking the class loader hierarchy on the second virtual machine to determine for each class loader in the hierarchy whether it has previously loaded the class, on the basis of said class loader cache in the second virtual machine; and
where the class has not been previously loaded and is to be loaded by a shared class loader, determining whether the class has been loaded into shared memory on the first virtual machine.
-
-
4. The method of claim 3, wherein if it is determined that the class has not been loaded into shared memory on the first virtual machine, the method further comprises the step of the second virtual machine causing the class to be loaded into the shared memory of the first virtual machine.
-
5. The method of claim 1, wherein garbage collection is disabled on the first virtual machine.
-
6. The method of claim 1, wherein the non-sharable data associated with the class in said mirror includes an identifier of the class loader which loaded the class and an initialisation flag.
-
7. The method of claim 6, wherein the initialisation flag in the non-sharable data is set to a non-initialised state when the class is first loaded into the second virtual machine.
-
8. The method of claim 6, wherein the non-sharable data associated with the class in said mirror further includes at least part of a method block and field data associated with the class.
-
9. The method of claim 8, wherein the sharable data associated with the class includes method code.
-
10. The method of claim 1, further comprising the steps of:
-
de-referencing all the mirrors of classes loaded into the second virtual machine by a particular shared class loader on that machine; and
allowing the particular shared class loader to be garbage collected on the second virtual machine.
-
-
11. A computing system including first and second virtual machines and having a shared memory accessible to both said first and second virtual machines, the system further comprising:
-
means for loading a class within the first virtual machine into said shared memory, said class having sharable and non-sharable data associated therewith;
means for loading the class into the second virtual machine by locating the class within said shared memory;
means for forming a mirror of the class within a private memory in the second virtual machine; and
means for utilising the class in the second virtual machine on the basis of the sharable data from the shared memory of the first virtual machine, and the non-sharable data from the private memory of the second virtual machine;
wherein said means for loading the class into the second virtual machine includes means for updating a class loader cache in the second virtual machine; and
wherein said first and second virtual machines both include a hierarchy of class loaders, at least one of which is a shared class loader wherein each shared class loader in the class loader hierarchy in second virtual machine has a corresponding shared class loader in the equivalent position in the class loader hierarchy in the first virtual machine. - View Dependent Claims (12, 13, 14, 15, 16, 17, 18, 19, 20)
means for checking that an instance of the shared class loader does not already exist; and
means for checking that there is a corresponding shared class loader in the first virtual machine, prior to creating a shared class loader in the second virtual machine.
-
-
13. The system of claim 11, wherein the means for loading the class into the second virtual machine by locating the class within said shared memory comprises:
-
means for walking the class loader hierarchy on the second virtual machine to determine for each class loader in the hierarchy whether it has previously loaded the class, on the basis of said class loader cache in the second virtual machine; and
means responsive to a class to be loaded by the shared class loader not being previously loaded, for determining whether the class has been loaded into shared memory on the first virtual machine.
-
-
14. The system of claim 13, wherein if it is determined that the class has not been loaded into shared memory on the first virtual machine, the second virtual machine causes the class to be loaded into the shared memory of the first virtual machine.
-
15. The system of claim 11, wherein garbage collection is disabled on the first virtual machine.
-
16. The system of claim 11, wherein the non-sharable data associated with the class in said mirror includes an identifier of the class loader which loaded the class and an initialisation flag.
-
17. The system of claim 16, wherein the initialisation flag in the non-sharable data is set to a non-initialised state when the class is first loaded into the second virtual machine.
-
18. The system of claim 16, wherein the non-sharable data associated with the class in said mirror further includes at least part of a method block and field data associated with the class.
-
19. The system of claim 18, wherein the sharable data associated with the class includes method code.
-
20. The system of claim 11, further comprising:
-
means for de-referencing all the mirrors of classes loaded into the second virtual machine by a particular shared class loader on that machine; and
means for allowing the particular shared class loader to be garbage collected on the second virtual machine.
-
-
21. A computing system including:
-
a first virtual machine;
a second virtual machine;
a shared memory accessible to both said first and second virtual machines;
a private memory accessible to the second virtual machine;
at least one class loaded in the first virtual machine into said shared memory, said class having sharable and non-sharable data associated therewith;
a mirror of said at least one class loaded in the second virtual machine into said private memory, said mirror including the non-sharable data associated with the at least one class;
wherein the at least one class is utilised by the second virtual machine on the basis of the sharable data from the shared memory of the first virtual machine, and the non-sharable data from the private memory of the second virtual machine wherein said second virtual machine loaded with said mirror of said at least one class includes an updated class loader cache in the second virtual machine; and
wherein said first and second virtual machines both include a hierarchy of class loaders, at least one of which is a shared class loader, wherein each shared class loader in the class loader hierarchy in second virtual machine has a corresponding shared class loader in the equivalent position in the class loader hierarchy in the first virtual machine.
-
-
22. A computer program product comprising a computer readable medium including computer program instructions thereon which when executed by a computer system create first and second virtual machines, said computer system having a shared memory accessible to both said first and second virtual machines, the computer program instructions implementing a method comprising the steps of:
-
loading a class within the first virtual machine into said shared memory, said class having sharable and non-sharable data associated therewith;
loading the class into the second virtual machine by locating the class within said shared memory;
forming a mirror of the class within a private memory in the second virtual machine; and
utilising the class in the second virtual machine on the basis of the sharable data from the shared memory of the first virtual machine, and the non-sharable data from the private memory of the second virtual machine;
wherein said step of loading the class into the second virtual machine includes updating a class loader cache in the second virtual machine; and
wherein said first and second virtual machines both include a hierarchy of class loaders, at least one of which is a shared class loader, wherein each shared class loader in the class loader hierarchy in second virtual machine has a corresponding shared class loader in the equivalent position in the class loader hierarchy in the first virtual machine. - View Dependent Claims (23, 24, 25, 26, 27, 28, 29, 30, 31)
checking that an instance of the shared class loader does not already exist; and
checking that there is a corresponding shared class loader in the first virtual machine.
-
-
24. The computer program product of claim 22, wherein the step of loading the class into the second virtual machine by locating the class within said shared memory comprises the steps of:
-
walking the class loader hierarchy on the second virtual machine to determine for each class loader in the hierarchy whether it has previously loaded the class, on the basis of said class loader cache in the second virtual machine; and
where the class has not been previously loaded and is to be loaded by a shared class loader, determining whether the class has been loaded into shared memory on the first virtual machine.
-
-
25. The computer program product of claim 24, wherein if it is determined that the class has not been loaded into shared memory on the first virtual machine, the computer program instructions further implement the step of the second virtual machine causing the class to be loaded into the shared memory of the first virtual machine.
-
26. The computer program product of claim 22, wherein garbage collection is disabled on the first virtual machine.
-
27. The computer program product of claims 22, wherein the non-sharable data associated with the class in said mirror includes an identifier of the class loader which loaded the class and an initialisation flag.
-
28. The computer program product of claim 27, wherein the initialisation flag in the non-sharable data is set to a non-initialised state when the class is first loaded into the second virtual machine.
-
29. The computer program product of claim 27, wherein the non-sharable data associated with the class in said mirror further includes at least part of a method block and field data associated with the class.
-
30. The computer program product of claim 29, wherein the sharable data associated with the class includes method code.
-
31. The computer program product of claim 22, wherein the instruction further implement the steps of:
-
de-referencing all the mirrors of classes loaded into the second virtual machine by a particular shared class loader on that machine; and
allowing the particular shared class loader to be garbage collected on the second virtual machine.
-
Specification