├── Assets ├── main.unity ├── Plugins │ ├── Android │ │ ├── memorychecker.jar │ │ └── memorychecker.jar.meta │ ├── iOS.meta │ ├── Android.meta │ └── iOS │ │ ├── memorychecker.mm.meta │ │ └── memorychecker.mm ├── main.unity.meta ├── Plugins.meta ├── Scripts.meta └── Scripts │ ├── UIViewUsedMemory.cs.meta │ └── UIViewUsedMemory.cs ├── README.md └── LICENSE /Assets/main.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takupisu/MemoryChecker-Unity/HEAD/Assets/main.unity -------------------------------------------------------------------------------- /Assets/Plugins/Android/memorychecker.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takupisu/MemoryChecker-Unity/HEAD/Assets/Plugins/Android/memorychecker.jar -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MemoryChecker-Unity 2 | Unityネイティブプラグイン(iOS&Android) 3 | 実機での使用メモリをチェックするプラグインです 4 | 5 | UnityNativePlugin(iOS&Android) 6 | Plug-in to check the use of the memory of the actual machine 7 | -------------------------------------------------------------------------------- /Assets/main.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f46d6093d650e45b2ad2832a4ba3346e 3 | timeCreated: 1472703195 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f3ca15e009d64bfc8b71db855a87560 3 | folderAsset: yes 4 | timeCreated: 1472703174 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09436f324d62c41e29dd4feff6f25e18 3 | folderAsset: yes 4 | timeCreated: 1472703213 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Plugins/iOS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d54fbef53055d4ae784f040134934c7b 3 | folderAsset: yes 4 | timeCreated: 1472710603 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Plugins/Android.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7119bfd525aec45c2bceaba4278b58db 3 | folderAsset: yes 4 | timeCreated: 1472703174 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scripts/UIViewUsedMemory.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44cf5bebdea4548bc8f656b814d51f45 3 | timeCreated: 1472703224 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Plugins/iOS/memorychecker.mm.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 552deb9d97ca242088aa942367566e5e 3 | timeCreated: 1472710648 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | platformData: 11 | Any: 12 | enabled: 0 13 | settings: {} 14 | Editor: 15 | enabled: 0 16 | settings: 17 | DefaultValueInitialized: true 18 | iOS: 19 | enabled: 1 20 | settings: {} 21 | userData: 22 | assetBundleName: 23 | assetBundleVariant: 24 | -------------------------------------------------------------------------------- /Assets/Plugins/Android/memorychecker.jar.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86b730b3bf4534076b71a02c7fc01254 3 | timeCreated: 1473689340 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | platformData: 11 | Android: 12 | enabled: 1 13 | settings: {} 14 | Any: 15 | enabled: 0 16 | settings: {} 17 | Editor: 18 | enabled: 0 19 | settings: 20 | DefaultValueInitialized: true 21 | userData: 22 | assetBundleName: 23 | assetBundleVariant: 24 | -------------------------------------------------------------------------------- /Assets/Plugins/iOS/memorychecker.mm: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | extern "C" { 5 | unsigned int getUsedMemorySize() { 6 | struct task_basic_info basic_info; 7 | mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT; 8 | kern_return_t status; 9 | 10 | status = task_info(current_task(), TASK_BASIC_INFO, (task_info_t)&basic_info, &t_info_count); 11 | 12 | if (status != KERN_SUCCESS) 13 | { 14 | NSLog(@"%s(): Error in task_info(): %s", __FUNCTION__, strerror(errno)); 15 | return -1; 16 | } 17 | 18 | return (unsigned int)basic_info.resident_size; 19 | } 20 | } -------------------------------------------------------------------------------- /Assets/Scripts/UIViewUsedMemory.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using UnityEngine.UI; 4 | using System.Runtime.InteropServices; 5 | 6 | public class UIViewUsedMemory : MonoBehaviour { 7 | 8 | [SerializeField] Text memoryText; 9 | 10 | #if UNITY_IOS 11 | [DllImport("__Internal")] 12 | private static extern int getUsedMemorySize(); 13 | #endif 14 | 15 | void Update () { 16 | float m = 0; 17 | #if UNITY_EDITOR 18 | m = ( System.GC.GetTotalMemory(false) + Profiler.usedHeapSize ) / 1024f; 19 | #elif UNITY_IOS 20 | m = getUsedMemorySize() / 1024f; 21 | #elif UNITY_ANDROID 22 | using ( AndroidJavaClass plugin = new AndroidJavaClass("com.veniegames.memorychecker.Main")){ 23 | m = plugin.CallStatic("getUsedMemorySize"); 24 | } 25 | #endif 26 | memoryText.text = m + "KB " + (m/1024f) + "MB"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Takumi Hanzawa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------