程序退出时,全局范围内的对象导致崩溃

时间:2019-05-09 04:49:02

标签: c++ memory

当t放在全局范围内时,它将尝试删除其存储的指针吗?

错误

SELECT * FROM Users WHERE Id = 1;
 sales.of.shampoo.over.a.three.ye <- read.csv("~/sales-of-shampoo-over-a-three-ye.csv")

>   View(sales.of.shampoo.over.a.three.ye)
> library(forecast)
This is forecast 8.7 
  Need help getting started? Try the online textbook FPP:
  http://OTexts.org/fpp2/
> autoplot(sales.of.shampoo.over.a.three.ye)
Error: Objects of type data.frame not supported by autoplot.
> library(txt)
Error in library(txt) : there is no package called ‘txt’
> library(xts)
Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package: base’:

    as.Date, as.Date.numeric

> SH<-as.xts(sales.of.shampoo.over.a.three.ye)
Error in as.POSIXlt.character(x, tz, ...) : 
  character string is not in a standard unambiguous format
kk(70137,0x1000d65c0) malloc: *** error for object 0x100b20940: pointer being freed was not allocated
kk(70137,0x1000d65c0) malloc: *** set a breakpoint in malloc_error_break to debug

2 个答案:

答案 0 :(得分:0)

由于static initialisation order fiasco go可以在componentAllocatorcollection之前构造,因此它们将以相反的顺序被破坏。然后,GameObject的析构函数将销毁一个Transform的销毁componentAllocator的销毁go

在这种情况下,最简单的解决方法是将main()对象移动到<AbsoluteLayout x:Name="MyLayout"> <Button Text="Add Label" HorizontalOptions="Center" VerticalOptions="EndAndExpand" Clicked="Button_Clicked" /> </AbsoluteLayout> 内,然后它将始终在静态变量之前被销毁。全局变量很少是必需的,并且经常会引起诸如此类的问题。

答案 1 :(得分:0)

  

但是,我认为问题略有不同。

不,不是。考虑您的最新修改:

未指定先破坏哪个对象,tTest::collection。当Test::collection首先被销毁时,析构函数Test::~Test()在已经死亡的集合上调用clear()。该析构函数反正将静态对象弄乱了是什么业务? Test的其他实例可能仍然存在,并依赖于静态成员数据。

怎么样:只是不做??您已经被告知多次。