Skip to content

Commit f41f47d

Browse files
committed
Remove memory calls that are not really supported anymore
1 parent 9e03c3a commit f41f47d

File tree

2 files changed

+6
-100
lines changed

2 files changed

+6
-100
lines changed

Assets/Plugins/WebGL/WebTools/WebToolPlugins.cs

Lines changed: 5 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ public static class WebToolPlugins
3434
private static extern string _GetUserAgent();
3535
[DllImport("__Internal")]
3636
private static extern uint _GetTotalMemorySize();
37-
[DllImport("__Internal")]
38-
private static extern uint _GetStaticMemorySize();
39-
[DllImport("__Internal")]
40-
private static extern uint _GetDynamicMemorySize();
4137
#endif
4238

4339
private static bool _infoPanelVisible = false;
@@ -154,82 +150,31 @@ public static bool IsMobileDevice()
154150
userAgent.Contains("Android");
155151
}
156152

157-
/// <summary>
158-
/// Get the total memory size used by the application in MB
159-
/// </summary>
160-
/// <returns>Size in MB</returns>
161-
public static float GetTotalMemorySize()
162-
{
163-
#if UNITY_WEBGL && !UNITY_EDITOR
164-
var bytes = _GetTotalMemorySize();
165-
return GetMegaBytes(bytes);
166-
#elif UNITY_EDITOR && WEBTOOLS_LOG_CALLS
167-
Debug.Log($"{nameof(WebToolPlugins)}.{nameof(GetTotalMemorySize)} called");
168-
return -1f;
169-
#else
170-
return -1f;
171-
#endif
172-
}
173-
174153
/// <summary>
175154
/// Log all current memory data in MB
176155
/// </summary>
177156
public static void LogMemory()
178157
{
179158
#if UNITY_WEBGL && !UNITY_EDITOR
180159
var managed = GetManagedMemorySize();
181-
var native = GetNativeMemorySize();
182160
var total = GetTotalMemorySize();
183-
Debug.Log($"Memory stats:\nManaged: {managed:0.00}MB\nNative: {native:0.00}MB\nTotal: {total:0.00}MB");
161+
Debug.Log($"Memory stats:\nManaged: {managed:0.00}MB\nTotal: {total:0.00}MB");
184162
#elif UNITY_EDITOR && WEBTOOLS_LOG_CALLS
185163
Debug.Log($"{nameof(WebToolPlugins)}.{nameof(LogMemory)} called");
186164
#endif
187165
}
188166

189167
/// <summary>
190-
/// Get the static memory size used by the application in MB
191-
/// </summary>
192-
/// <returns>Size in MB</returns>
193-
public static float GetStaticMemorySize()
194-
{
195-
#if UNITY_WEBGL && !UNITY_EDITOR
196-
var bytes = _GetStaticMemorySize();
197-
return GetMegaBytes(bytes);
198-
#elif UNITY_EDITOR && WEBTOOLS_LOG_CALLS
199-
Debug.Log($"{nameof(WebToolPlugins)}.{nameof(GetStaticMemorySize)} called");
200-
return -1f;
201-
#else
202-
return -1f;
203-
#endif
204-
}
205-
206-
/// <summary>
207-
/// Get the dynamic memory size used by the application in MB
168+
/// Get the total memory size used by the application in MB
208169
/// </summary>
209170
/// <returns>Size in MB</returns>
210-
public static float GetDynamicMemorySize()
171+
public static float GetTotalMemorySize()
211172
{
212173
#if UNITY_WEBGL && !UNITY_EDITOR
213-
var bytes = _GetStaticMemorySize();
174+
var bytes = _GetTotalMemorySize();
214175
return GetMegaBytes(bytes);
215176
#elif UNITY_EDITOR && WEBTOOLS_LOG_CALLS
216-
Debug.Log($"{nameof(WebToolPlugins)}.{nameof(GetDynamicMemorySize)} called");
217-
return -1f;
218-
#else
219-
return -1f;
220-
#endif
221-
}
222-
223-
/// <summary>
224-
/// Get the native memory size used by the application in MB (Static + Dynamic memory)
225-
/// </summary>
226-
/// <returns>Size in MB</returns>
227-
public static float GetNativeMemorySize()
228-
{
229-
#if UNITY_WEBGL && !UNITY_EDITOR
230-
return GetDynamicMemorySize() + GetStaticMemorySize();
231-
#elif UNITY_EDITOR && WEBTOOLS_LOG_CALLS
232-
Debug.Log($"{nameof(WebToolPlugins)}.{nameof(GetNativeMemorySize)} called");
177+
Debug.Log($"{nameof(WebToolPlugins)}.{nameof(GetTotalMemorySize)} called");
233178
return -1f;
234179
#else
235180
return -1f;

Assets/Plugins/WebGL/WebTools/WebToolPlugins.jslib

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var WebGlPlugins =
4646
}
4747

4848
var currentTimeRounded = currentTime.toFixed(2);
49-
console.log('Time tracker event ' +eventNameText +': ' + currentTimeRounded + 'ms');
49+
console.log('Time tracker event ' + eventNameText + ': ' + currentTimeRounded + 'ms');
5050
},
5151

5252
_AddFpsTrackingEvent: function(fps) {
@@ -97,45 +97,6 @@ var WebGlPlugins =
9797

9898
console.warn("Problem with retrieving total memory size");
9999
return -1;
100-
},
101-
102-
_GetTotalStackSize: function()
103-
{
104-
if(typeof Module !== 'undefined' && typeof Module.STACK_SIZE !== 'undefined') {
105-
return Module.STACK_SIZE;
106-
}
107-
if(typeof TOTAL_STACK !== 'undefined') { // Legacy support
108-
return TOTAL_STACK;
109-
}
110-
111-
console.warn("Problem with retrieving stack size");
112-
return -1;
113-
},
114-
115-
_GetStaticMemorySize: function()
116-
{
117-
if(typeof Module !== 'undefined' && typeof Module.staticAlloc !== 'undefined') {
118-
return Module.staticAlloc;
119-
}
120-
if(typeof STATICTOP !== 'undefined' && typeof STATIC_BASE !== 'undefined') { // Legacy support
121-
return STATICTOP - STATIC_BASE;
122-
}
123-
124-
console.warn("Problem with retrieving static memory size");
125-
return -1;
126-
},
127-
128-
_GetDynamicMemorySize: function()
129-
{
130-
if(typeof Module !== 'undefined' && typeof Module.dynamicAlloc !== 'undefined') {
131-
return Module.dynamicAlloc;
132-
}
133-
if(typeof HEAP32 !== 'undefined' && typeof DYNAMICTOP_PTR !== 'undefined' && typeof DYNAMIC_BASE !== 'undefined') { // Legacy support
134-
return HEAP32[DYNAMICTOP_PTR >> 2] - DYNAMIC_BASE;
135-
}
136-
137-
console.warn("Problem with retrieving dynamic memory size");
138-
return -1;
139100
}
140101
};
141102

0 commit comments

Comments
 (0)