<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Выгрузка переменной из памяти]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=10814</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=10814&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Выгрузка переменной из памяти».]]></description>
		<lastBuildDate>Wed, 22 Jul 2015 15:21:23 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Выгрузка переменной из памяти]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=95884#p95884</link>
			<description><![CDATA[<p>Понял, спасибо большое.</p>]]></description>
			<author><![CDATA[null@example.com (MoZg)]]></author>
			<pubDate>Wed, 22 Jul 2015 15:21:23 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=95884#p95884</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Выгрузка переменной из памяти]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=95868#p95868</link>
			<description><![CDATA[<p>Вот, собственно:<br /></p><div class="codebox"><pre><code>MsgBox, Пустое сообщение для выделения памяти под него

PrevMemory := WorkingSetPrivate()
MsgBox, % &quot;Память, занимаемая скриптом до выделеня памяти переменным: &quot; PrevMemory &quot; КБ&quot;

VarSetCapacity(MyVar1, 262144, 123)  ; 256 КБ
VarSetCapacity(MyVar2, 262144, 123)  ; 256 КБ

CurrentMemory := WorkingSetPrivate()
MsgBox, % &quot;Память, занимаемая скриптом после выделеня 512 КБ памяти переменным: &quot; CurrentMemory &quot; КБ`nРазница: &quot; CurrentMemory - PrevMemory &quot; КБ&quot;
PrevMemory := CurrentMemory

VarSetCapacity(MyVar1, 0)
CurrentMemory := WorkingSetPrivate()
MsgBox, % &quot;Память, занимаемая скриптом после освобождения первой переменной через VarSetCapacity(MyVar1, 0): &quot; CurrentMemory &quot; КБ`nРазница: &quot; CurrentMemory - PrevMemory &quot; КБ&quot;
PrevMemory := CurrentMemory

MyVar2 := &quot;&quot;
CurrentMemory := WorkingSetPrivate()
MsgBox, % &quot;Память, занимаемая скриптом после освобождения второй переменной путём сохранения в ней пустого значения: &quot; CurrentMemory &quot; КБ`nРазница: &quot; CurrentMemory - PrevMemory &quot; КБ&quot;

WorkingSetPrivate()
{
   command := &quot;Select * from Win32_PerfFormattedData_PerfProc_Process Where IDProcess=&quot; DllCall(&quot;GetCurrentProcessId&quot;)
   for process in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(command)
      Return process.WorkingSetPrivate//1024
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 22 Jul 2015 13:31:45 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=95868#p95868</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Выгрузка переменной из памяти]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=95867#p95867</link>
			<description><![CDATA[<p>Предыдущий пост цитировать не <a href="http://forum.script-coding.com/viewtopic.php?id=6148">нужно</a>.<br />Вы про вариант <em>myVar := &quot;&quot;</em>? Так в справке <a href="http://ahkscript.org/docs/commands/VarSetCapacity.htm">написано</a>:<br /></p><div class="quotebox"><blockquote><p>For performance reasons, the memory of a variable whose capacity is less than 4096 bytes is not freed by storing an empty string in it (e.g. Var := &quot;&quot;). However, VarSetCapacity(Var, 0) does free it.</p></blockquote></div><p>Соответственно, можно сделать вывод, что если переменная больше 4096, вариант <em>myVar := &quot;&quot;</em> должен подойти. Если хотите быть уверенным на 100% — можете просто проэкспериментировать. Лично я для переменных, имеющих более или менее значительный объём, всегда пользуюсь первым вариантом. Если же в переменной всего несколько байт, то можно не заморачиваться.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 22 Jul 2015 12:28:42 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=95867#p95867</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Выгрузка переменной из памяти]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=95866#p95866</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Если в переменной меньше 4096 байт, то<br /></p><div class="codebox"><pre><code>VarSetCapacity(myVar, 0)</code></pre></div><p>иначе просто<br /></p><div class="codebox"><pre><code>myVar := &quot;&quot;</code></pre></div><p>Первый вариант подойдёт в любом случае.</p></blockquote></div><p>Хотите сказать что если сделать переменную пустой, то она не будет грузить оперативку?<br />Для меня это странно т.к. в C++ int a; (определение пустой переменной типа int) выделяет память, т.е. переменная пустая, а память то выделана пот переменную.</p>]]></description>
			<author><![CDATA[null@example.com (MoZg)]]></author>
			<pubDate>Wed, 22 Jul 2015 12:18:49 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=95866#p95866</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Выгрузка переменной из памяти]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=95865#p95865</link>
			<description><![CDATA[<p>Если в переменной меньше 4096 байт, то<br /></p><div class="codebox"><pre><code>VarSetCapacity(myVar, 0)</code></pre></div><p>иначе просто<br /></p><div class="codebox"><pre><code>myVar := &quot;&quot;</code></pre></div><p>Первый вариант подойдёт в любом случае.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 22 Jul 2015 12:13:53 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=95865#p95865</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Выгрузка переменной из памяти]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=95860#p95860</link>
			<description><![CDATA[<p>Как мне выгрузить переменную из памяти? К примеру, мне надо выгрузить переменную myVar, как это реализовать?</p><p>P.S. В C/C++ для этого используют указатель на переменную (int *myVar = new myVar), а потом просто delete myVar;</p>]]></description>
			<author><![CDATA[null@example.com (MoZg)]]></author>
			<pubDate>Wed, 22 Jul 2015 11:58:00 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=95860#p95860</guid>
		</item>
	</channel>
</rss>
