我正在编写一个完全由AJAX驱动的浏览器应用程序(我生命中的第一次),这意味着:
我担心的是我应该怎么做XMLHttpRequests,因为我主要是C++程序员,当你写一个像
x = new XMLHttpRequest();
Run Code Online (Sandbox Code Playgroud)
之后你需要delete
它.
这个问题完全是关于内存管理的,无论这个对象是否new
在内存中分配,即使它在readyState == 4完成它的"循环"之后,或者以某种方式释放,释放,whatchacallit?老实说,我不知道它可以在什么时候被释放,因为创建这些的脚本将在HEAD并且可能整个工作日坐在那里.我是否应该:
考虑到我的网页的"框架"将保留,请在什么时候包括您的答案以及为什么要删除这些对象,如果他们愿意的话.希望我明白这个问题,并感谢任何有见地的答案.
编辑:
考虑onClick
事件处理程序的代码(我删除了许多正在检查意外返回值的行)以创建XMLHttpRequest并发送它:
function submitme(){
var p = document.getElementById('p'); //a text field being sent to server
if(typeof p!='undefined' && p!=null){
if(p.value!=""){
//here XMLHttpRequest is created, this function
//returns exactly object of this type or false, when failed
var xhr=createXmlHttpRequestObject();
if(xhr!=false){
xhr.open("POST", "blablabla.php", true);
xhr.onreadystatechange=function(){
if(xhr.readyState==4){
if(xhr.status==200){
//result will be posted in this div below
var adiv = document.getElementById('resultdiv');
//extract …
Run Code Online (Sandbox Code Playgroud) i am working on making my applications international. After two days digging on msdn i came up with a test, which loads language-specific library containing resources. This is also my first attempt at loading library as a resource, loading strings from it and so on.
Next, according to msdn example at http://msdn.microsoft.com/en-us/library/windows/desktop/dd319071%28v=VS.85%29.aspx, i'm trying the LoadString.
由于整个应用程序的字符串加载等于大量的文本复制,我想我会使用 LoadString 的 - 我认为是 - 内存高效功能,它将 nBufferMax 参数设置为零。根据 LoadString 文档,它应该返回一个指向字符串资源的指针。我想我会创建一个结构体或一类字符串指针,然后按照这些方式做一些事情(我只提取了重要的部分):
wchar_t textBuf[SOMEVALUE]; // <-- this is how id DOES work
wchar_t *myString; …
Run Code Online (Sandbox Code Playgroud) 我正在使用Firebird 2.5.1 Embedded。我已经按照通常的方法清空了近200k行的表:
delete from SZAFKI
Run Code Online (Sandbox Code Playgroud)
这是输出,需要16秒,这是不可接受的。
Preparing query: delete from SZAFKI
Prepare time: 0.010s
PLAN (SZAFKI NATURAL)
Executing...
Done.
3973416 fetches, 1030917 marks, 116515 reads, 116434 writes.
0 inserts, 0 updates, 182658 deletes, 27 index, 182658 seq.
Delta memory: -19688 bytes.
SZAFKI: 182658 deletes.
182658 rows affected directly.
Total execution time: 16.729s
Script execution finished.
Run Code Online (Sandbox Code Playgroud)
Firebird没有TRUNCATE关键字。当查询使用PLAN NATURAL时,我尝试手动进行查询计划,如下所示:
delete from szafki PLAN (SZAFKI INDEX (SZAFKI_PK))
Run Code Online (Sandbox Code Playgroud)
但是Firebird说“ SZAFKI_PK无法在指定计划中使用”(这是主键)问题是如何有效清空表?无法删除和重新创建。
我目前正在使用pugi xml,我经常使用这样的循环:
for (pugi::xml_node sth: root.child("name").children())
{
//do something
}
Run Code Online (Sandbox Code Playgroud)
然后在某些时候我意识到我需要在WHICH迭代中保存信息,我找到了一些值,因为稍后需要在此循环之外.我可以在不添加计数器的情况下判断我正在进行哪次迭代吗?
此外,如果该对象是这样的矢量:
std::vector<type> vtr;
for (std::vector<type>::iterator it = vtr.begin(); it != vtr.end(); ++it)
{
//which iteration?
}
Run Code Online (Sandbox Code Playgroud) c++ ×2
ajax ×1
firebird ×1
javascript ×1
pugixml ×1
sql ×1
sql-delete ×1
stdvector ×1
truncate ×1
winapi ×1