• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <memory>
16 
17 #include "hiview_platform.h"
18 #include "hiview_service.h"
19 
20 #include "defines.h"
21 #include "logger.h"
22 #include "memory_util.h"
23 
24 DEFINE_LOG_TAG("HiView-Main");
25 using namespace OHOS::HiviewDFX;
26 
main(int argc __UNUSED,char * argv[]__UNUSED)27 int main(int argc __UNUSED, char* argv[] __UNUSED)
28 {
29     if (MemoryUtil::DisableThreadCache() != 0 || MemoryUtil::DisableDelayFree() != 0) {
30         HIVIEW_LOGW("Failed to optimize memory for current thread");
31     }
32 
33     auto& hiview = HiviewPlatform::GetInstance();
34     // process cmdline
35     hiview.ProcessArgsRequest(argc, argv);
36 
37     // parse configs and load plugin
38     if (!hiview.InitEnvironment()) {
39         HIVIEW_LOGW("Fail to init plugin environment. exit");
40         return -1;
41     }
42 
43     // start service
44     auto hiviewService = std::make_unique<HiviewService>();
45     hiviewService->StartService();
46     return 0;
47 }
48