{"action":"opened","issue":{"url":"https://api.github.com/repos/mono/mono/issues/15199","repository_url":"https://api.github.com/repos/mono/mono","labels_url":"https://api.github.com/repos/mono/mono/issues/15199/labels{/name}","comments_url":"https://api.github.com/repos/mono/mono/issues/15199/comments","events_url":"https://api.github.com/repos/mono/mono/issues/15199/events","html_url":"https://github.com/mono/mono/issues/15199","id":456728652,"node_id":"MDU6SXNzdWU0NTY3Mjg2NTI=","number":15199,"title":"how can I construct the generic sharing case?","user":{"login":"srxqds","id":5187024,"node_id":"MDQ6VXNlcjUxODcwMjQ=","avatar_url":"https://avatars1.githubusercontent.com/u/5187024?v=4","gravatar_id":"","url":"https://api.github.com/users/srxqds","html_url":"https://github.com/srxqds","followers_url":"https://api.github.com/users/srxqds/followers","following_url":"https://api.github.com/users/srxqds/following{/other_user}","gists_url":"https://api.github.com/users/srxqds/gists{/gist_id}","starred_url":"https://api.github.com/users/srxqds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srxqds/subscriptions","organizations_url":"https://api.github.com/users/srxqds/orgs","repos_url":"https://api.github.com/users/srxqds/repos","events_url":"https://api.github.com/users/srxqds/events{/privacy}","received_events_url":"https://api.github.com/users/srxqds/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-06-17T03:44:49Z","updated_at":"2019-06-17T03:44:49Z","closed_at":null,"author_association":"NONE","body":"I want to figure out when mono alloc **MonoGSharedVtMethodInfo**, **MonoRuntimeGenericContextInfoTemplate**, **MonoJumpInfoGSharedVtCall** and other type in mini-generic-sharing.c.\r\n\r\nI want to implement to free the memory alloc by domain, So I want to construct the generic sharing case which can run into below(just some of all them) alloc code: \r\n```c\r\nres = (MonoJumpInfoVirtMethod *)mono_domain_alloc0 (domain, sizeof (MonoJumpInfoVirtMethod));\r\n```\r\n\r\n```c\r\nres = (MonoGSharedVtMethodInfo *)mono_domain_alloc0 (domain, sizeof (MonoGSharedVtMethodInfo));\r\n```\r\n\r\n```c\r\nres = (MonoJumpInfoGSharedVtCall *)mono_domain_alloc0 (domain, sizeof (MonoJumpInfoGSharedVtCall));\r\n```\r\n\r\nThe csharp case I try:\r\n```c#\r\n    public class GenA<T>\r\n    {\r\n        static T[] arr;\r\n\r\n        static GenA()\r\n        {\r\n            arr = new T[3];\r\n        }\r\n\r\n        public GenA() { }\r\n\r\n        public GenA<T> newGen()\r\n        {\r\n            return new GenA<T>();\r\n        }\r\n\r\n        public GenA<int> newGenInt()\r\n        {\r\n            return new GenA<int>();\r\n        }\r\n\r\n        public T[] getArr()\r\n        {\r\n            return arr;\r\n        }\r\n\r\n        public T[] newArr()\r\n        {\r\n            return new T[3];\r\n        }\r\n\r\n        public int hash(T obj)\r\n        {\r\n            return obj.GetHashCode();\r\n        }\r\n\r\n        public T ident(T obj)\r\n        {\r\n            return obj;\r\n        }\r\n\r\n        public T cast(Object obj)\r\n        {\r\n            return (T)obj;\r\n        }\r\n    }\r\n\r\n        public static void TestGenericArg<T>(TestGeneric<T> value)\r\n        {\r\n\r\n        }\r\n\r\n        public static void Swap<T>(T[] a, int i, int j) where T:struct\r\n        {\r\n            T t = a[i];\r\n            a[i] = a[j];\r\n            a[j] = t;\r\n        }\r\n\r\n        public static T TestT<T>(T a)\r\n        {\r\n            return a;\r\n        }\r\n```\r\n\r\nBut it don't make the generic sharing.\r\n\r\nhow can I make it?"}}
{"actor":{"display_login":"srxqds"}}